Skip to content

WSGI middleware should unquote path_info #89

Merged
vrdmr merged 1 commit intoAzure:devfrom
mcuckson:bug/fix-path-info-encoding
Mar 9, 2022
Merged

WSGI middleware should unquote path_info #89
vrdmr merged 1 commit intoAzure:devfrom
mcuckson:bug/fix-path-info-encoding

Conversation

@mcuckson
Copy link
Copy Markdown
Contributor

@mcuckson mcuckson commented May 11, 2021

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?

@vrdmr
Copy link
Copy Markdown
Member

vrdmr commented Mar 9, 2022

Thanks, @mcuckson for the changes, and apologies for the delay.

@vrdmr vrdmr merged commit 5fff034 into Azure:dev Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants