Closed FuryFiber closed 3 months ago
Hi! Your code has mutliple problems:
application/x-www-form-urlencoded
content type is for text-based form data, use text data for application/x-www-form-urlencoded or switch to application/octet-stream for binary data_parse_urlencoded()
method with this text UnicodeDecodeError('utf-8', b'\x80', 0, 1, 'invalid start byte')
. Guys, do we need handle this case, even invalid request was provided ?Yes i am aware that what i do here is never really supposed to happen. However i still feel like the error that is returned is not the correct one.
After looking at the history of this code, and PR #2931 from @Dart-net, I've realized that this is a symptom of a different issue.
multipart/form-data
and application/x-www-form-urlencoded
to raise RequestEntityTooLarge
if there were too many fields.urlencoded
forms don't suffer the same parse issue as multipart
and didn't need this limit. The limit argument was removed in #2694, but the except ValueError
was kept.bytes.decode()
can raise UnicodeDecodeError
, which is a subclass of ValueError
, so it was being caught and turned into a ReequestEntityTooLarge
error incorrectly.ValueError
if silent=False
(the default).Therefore, to actually revert to the prior behavior, we should have remove the except ValueError: raise RequestEntityTooLarge
, and the code would have gone back to ignoring completely invalid data.
Bug
When sending non utf-8 bytes into a form the flask server responds with
413 - RequestEntityTooLarge
. This does not seem like the appropriate http error to return in this case. This happens when using a flask app however it might be a bug in werkzeug.Reproduce unexpected behaviour:
app.py:
home.html:
bug.py:
Environment: