defnull / multipart

A fast multipart/form-data parser for python
https://multipart.readthedocs.io/
MIT License
135 stars 33 forks source link

repaired "application/x-www-form-urlencoded", "application/x-url-enco… #45

Closed hakiKhuva closed 3 months ago

hakiKhuva commented 1 year ago

removed line that read 1 next character from the stream and using CONTENT_LENGTH to read the content of the wsgi.input or stream variable.

If the CONTENT_LENGTH is more than the memory limit than the error is raised before reading the content of stream.

defnull commented 3 months ago

Not sure which problem this PR should fix. If there is a valid Content-Length header, than reading one more byte should be blocked by the WSGI server and return nothing, which is exactly what is tested for here. But if the content length is unknown (-1), we should read up to mem_limit and fail if we detect that there is more data we cannot parse. This PR removed that check and may return incomplete results instead of failing, which I'd say is way worse than a clean exception.