fix: normalize unicode url_prefix to match PEP 3333 path encoding - #493
fix: normalize unicode url_prefix to match PEP 3333 path encoding#493gaoflow wants to merge 2 commits into
Conversation
kgaughan
left a comment
There was a problem hiding this comment.
This looks fine, but for some reason the CI pipeline didn't trigger. Could you update CONTRIBUTORS.txt and CHANGES.txt? Those need updating anyway, and pushing an additional changeset should give Github a poke that it needs.
Also, was this generated by an LLM or is it your own work.
|
CHANGES.txt entry added in 1bd6c93 — the push should give CI the poke it needed. On CONTRIBUTORS.txt: that list is the contributor-agreement signature, so the account owner will add their name themselves rather than me doing it on their behalf. And to answer your question directly: yes, the PR is AI-assisted — drafted by an AI coding agent under the account owner's direction and reviewed by them before submission. |
|
OK, that's potentially problematic. I'll have to raise this in the Pylons Discord. |
|
Also, I want to avoid reputation laundering. |
|
Totally fair — the account owner is a real person and stands behind the work, but if the project would rather not take AI-assisted PRs, happy to close this one. No hard feelings either way. |
Summary
When
url_prefixcontains non-ASCII characters (e.g.,ü), it fails to match the request path because the two are stored in incompatible encodings:unquote_bytes_to_wsgi()which percent-decodes the raw URL bytes and decodes the result as ISO-8859-1 (PEP 3333 convention).strwithout encoding normalization.This means the WSGI application receives an incorrect
PATH_INFO— the url_prefix is never stripped — and theSCRIPT_NAMEis not reported in the correct PEP 3333 encoding.Fix
Normalize the url_prefix in
slash_fixed_strby encoding the user-supplied Unicode string as UTF-8 and then decoding as ISO-8859-1, matching the convention used by the HTTP request parser. For ASCII-only prefixes this is a no-op.Testing
Added
test_url_prefix_unicode_normalizationthat verifies:All 794 existing tests pass (10 skipped, same as before).
Closes #492