Description
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.
Activity