WSGI middleware should unquote path_info #89
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I believe that the environ PATH_INFO attribute should be unquoted when it is passed through. This is replicates the functionality of Gunicorn (https://github.com/pallets/werkzeug/blob/5a2bf35441006d832ab1ed5a31963cbc366c99ac/werkzeug/serving.py#L98) and Werkzeug (https://github.com/benoitc/gunicorn/blob/cf55d2cec277f220ebd605989ce78ad1bb553c46/gunicorn/http/wsgi.py#L184)
There is a more detailed explanation of this in the Gunicorn project - benoitc/gunicorn#1211 - but in short PEP 333 implicitly describes restructuring the url - https://www.python.org/dev/peps/pep-3333/#url-reconstruction.
The reason for raising this is that I have a Flask app which exhibits different behaviour when running under Azure Functions via the wsgi middleware. I have raised the PR to demonstrate the logic of Gunicorn, but I am happy to open a debate on this functionality and alternatives as obviously a change could cause side effects for existing users currently expecting the path to be quoted. Perhaps an ability to toggle the unquoting behaviour as a caller would be more appropriate?