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

MultiPartParser skips fields when sending empty files #2235

Open
27justin opened this issue Dec 22, 2024 · 0 comments
Open

MultiPartParser skips fields when sending empty files #2235

27justin opened this issue Dec 22, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@27justin
Copy link

Describe the bug
MultiPartParser does not parse the request body correctly when an empty file is transmitted as the first member of the body.

To Reproduce

  1. Create a POST Endpoint that reads out the multipart body.
  2. Create a sample HTML page that has a <input type="file" /> as the first input in a form
  3. Add more of whatever types
  4. Dispatch the form without supplying a file
  5. Endpoint reads out no parameters

Expected behavior
The MultiPartParser should return the request body with the parameters set.
Currently, MultiPartParser::parse returns -1 with an empty <input type="file" />

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Linux
  • Browser: Firefox
  • Version: 133.0.3

The bug also occurs on chrome.

Additional context
The implementation of MultiPartParser::parseEntity is faulty in that it expects each multi-part file to have a filename.
When sending a form that has no filename set, the parser stops parsing subsequent fields.
The offending code is the conditional at MultiPart.cc:214

Here's an excerpt of the failing request body:

-----------------------------105238891342303886541107959621
Content-Disposition: form-data; name="cover"; filename=""
Content-Type: application/octet-stream


-----------------------------105238891342303886541107959621
Content-Disposition: form-data; name="abstract"

test
-----------------------------105238891342303886541107959621
Content-Disposition: form-data; name="language"

test
-----------------------------105238891342303886541107959621--
@an-tao an-tao added the enhancement New feature or request label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants