Skip to content

Decode non-ASCII request paths and WSGI query strings - #378

Open
gyanu2507 wants to merge 1 commit into
pgjones:mainfrom
gyanu2507:fix/non-ascii-request-path
Open

gyanu2507 wants to merge 1 commit into
pgjones:mainfrom
gyanu2507:fix/non-ascii-request-path

Conversation

@gyanu2507

Copy link
Copy Markdown

A request path with raw UTF-8 bytes, such as /café, crashed in path.decode("ascii") before the app ran. Percent-encoded UTF-8 already worked.

decode_path uses UTF-8, then latin-1 when the bytes are not UTF-8. WSGI QUERY_STRING is decoded as latin-1, which is the PEP 3333 native-string encoding, so a non-ASCII query no longer raises either.

A raw UTF-8 path crashed on ascii decode before the app ran. Paths now decode as UTF-8, with latin-1 for bytes that are not UTF-8. QUERY_STRING uses latin-1 so the WSGI bytes round-trip.

This branch has not been deployed

No deployments
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.

1 participant