Skip to content
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

PEP 3333: URL-decoding and routing #3280

Open
kefir- opened this issue Aug 8, 2023 · 3 comments
Open

PEP 3333: URL-decoding and routing #3280

kefir- opened this issue Aug 8, 2023 · 3 comments

Comments

@kefir-
Copy link

kefir- commented Aug 8, 2023

There have been several discussions over the years about how WSGI frameworks apply routing in the case of URL-encoded path components. Here's a comment that links to a few of the discussions:

encode/starlette#1828 (comment)

The issue is that when using routing features, the URL /user/foo/edit appears to be indistinguishable from /user/foo%2Fedit, and in case of routing rules for /user/{username} and /user/{username}/edit, the URL /user/foo%2Fedit will match the second rule and not the first.

This seems to me to be in conflict with RFC 3986 section 2.4 and RFC 3986 section 2.2. The latter states:

URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent.

But the routing mechanism in popular WSGI frameworks such as Flask and FastAPI are unable to differentiate the mentioned URLs, because the URI's percent-encoding is decoded before the routing happens.

I believe PEP-3333 needs to clarify the correct behaviour.

@hugovk hugovk changed the title PEP-3333, URL-decoding and routing PEP 3333: URL-decoding and routing Aug 16, 2023
@mahamad1234

This comment was marked as spam.

@Karliz24

This comment was marked as spam.

@amak
Copy link
Contributor

amak commented Jan 29, 2024

This issue was discussed in detail in 2008

[Web-SIG] WSGI Amendments thoughts: the horror of charsets
https://www.mail-archive.com/[email protected]/msg02483.html

It's a complex situation, I think that there is no straightforward answer.

I think it likely that the only way that the WSGI spec will change in relation to this issue is if there is a specific change proposed.

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

No branches or pull requests

6 participants
@amak @kefir- @mahamad1234 @Karliz24 and others