Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why upload_pass_form_field does not work #140

Open
chenm0520 opened this issue Jul 11, 2022 · 3 comments
Open

why upload_pass_form_field does not work #140

chenm0520 opened this issue Jul 11, 2022 · 3 comments

Comments

@chenm0520
Copy link

the version of nginx is 1.22.0 and use the lastest nginx-upload-module,this is my nignx conf:
`

     location /upload/ {
    # Pass altered request body to this location
    upload_pass /deal.php;
    # Store files to this directory
    # The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
    upload_store /home/www/upload;

    # Allow uploaded files to be read only by user
    #upload_store_access www:r;

    # Set specified fields in request body
    upload_set_form_field $upload_field_name.name "$upload_file_name";
    upload_set_form_field $upload_field_name.content_type "$upload_content_type";
    upload_set_form_field $upload_field_name.path "$upload_tmp_path";

    # Inform backend about hash and size of a file
    upload_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5";
    upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size";

    upload_pass_form_field "^.*$";

    upload_cleanup 400 404 499 500-505;
}

`
the "deal.php" only prints the global variable $_REQUEST,
and I try to use POSTMAN to send the post request,get the following result:
image
since I set "upload_pass_form_field" with "^.*$",then all the post fields will be appended,why can't field of "submit" occur?

@amlan-sw
Copy link

I have same problem. I think the problem is nginx 1.22.0 now use PCRE2 as default regex engine and http_upload_module maybe must be update to follow new regex engine to prcess upload_pass_form_field.

for my need, I have "hack" solution to bypass upload_pass_form_field, meaning all form wiill be passed, maybe just like your configuration:

upload_pass_form_field "^.*$";

you just want to pass all form field

the patch: at file ngx_http_upload_module.c

line 1584:
before
if(pass_field && u->field_name.len != 0) {

just add:

pass_field = 1;

rebuild nginx and now all field will be pass, and for future nginx.conf, you don need use upload_pass_form_field

@chenm0520
Copy link
Author

@amlan-sw ,I get it,thanks,at present only the case

@dup2
Copy link

dup2 commented Feb 5, 2023

You can also compile nginx without PCRE2 using --without-pcre2 and --with-ld-opt="-lpcre" to force PCRE usage. This restores the old regexp match behaviour

maber1993 added a commit to maber1993/nginx-upload-module that referenced this issue Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants