-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
werkzeug.urls.uri_to_iri
is incompatible with host
parsing for request.url
in flask
#3033
Comments
What did you expect instead? You sent invalid data and got an error. |
I didn't send invalid data. Some random attacker did. I don't expect an exception. And one isn't documented here: https://flask.palletsprojects.com/en/stable/api/#flask.Request.url
That said, there are platforms where one can do something like Alternatively, an exception that includes all of the pieces so that I could manually deal w/ them would be appreciated. |
Documentation in Python in general doesn't list every way a thing can fail at any level when given invalid data. I don't plan to add support for non-int ports. What pieces need to be in the exception for you? It seems it's already there: the port is not an int. Also note that this is coming from |
Enough information for me to rebuild the url by hand. The underlying It's possible I should have filed this against Flask instead of werzeug. As a consumer, I naively assumed the two projects cooperated (the versioning seemed to be fairly close to lockstep). It looks like a user should avoid using The point of the code in question is to log a request for debugging purposes. If a client sent garbage, the logging needs to be able to show the garbage the client sent. |
Note that I filed this here because an older version of this module didn't have this behavior and it wasn't listed in the changelog for the function Lines 71 to 81 in 7868bef
|
In general, that's not a goal of our exceptions, or of exceptions in Python in general. Logging the URL regardless of subsequent processing would typically happen at the HTTP or WSGI server level, not at the WSGI app request processing level.
Because nothing specific changed to be called out. We did a huge switch to |
request.url
-- https://github.com/GarnerCorp/nginx-debugging-backend/blob/main/debug.pycurl
request with-H 'host: 127.0.0.1:y'
to the flask appThe app line is approximately:
https://github.com/GarnerCorp/nginx-debugging-backend/blob/5a2adfb27340dc35ef02b848e404b139fea38c59/debug.py#L134
werkzeug/src/werkzeug/utils.py
Line 107 in 7868bef
werkzeug/src/werkzeug/sansio/request.py
Line 208 in 7868bef
werkzeug/src/werkzeug/sansio/utils.py
Line 145 in 7868bef
werkzeug/src/werkzeug/urls.py
Lines 98 to 99 in 7868bef
Fwiw, flask 2 w/ werkzeug 2.0.2 doesn't die (because it doesn't have this fancy port reconstruction code).
The text was updated successfully, but these errors were encountered: