rwf2 / multer

An async parser for multipart/form-data content-type in Rust
MIT License
156 stars 35 forks source link

Fix: extract_from is too strict #53

Closed bertof closed 7 months ago

bertof commented 1 year ago

ContentDispositionAttr::extract_from is too strict, requiring form-data fileds to be in a specific order. The standard also allows name and filename arguments to swap their position.

This commit:

Both tests and fuzzing are passing. Performance regression needs to be tested.

SergioBenitez commented 7 months ago

Your commit rewrote the entire parse method, but the actual change needed was only a few lines of code. I went ahead and added those few lines of code in https://github.com/rousan/multer-rs/commit/bca313f36a336494eba2eb6c7cb6cfc03252cb79, as well as a few other improvements, but kept your test case. I also removed the fuzzing seed: the fuzzer is only checking for panics, not valid parsing, so another seed for a valid parse doesn't add to the fuzzer's ability to find an issue.

Thank you for bringing this to my attention, however! In general, I would advise making the smallest change possible to accomplish the task you're seeking. If nothing else, it makes reviewing your change easier and decreases the chance that a regression is introduced.