python / python/peps

PEP 3333: URL-decoding and routing

Offen
#3,280 3 Kommentare 7 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
reStructuredText
Sterne
5k
Forks
1.8k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
25

Beschreibung

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:

https://github.com/encode/starlette/pull/1828#issuecomment-1434043248

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit der Lektüre von PEP 3333 und der verlinkten Starlette-Diskussion und vergleichen Sie anschließend das dort beschriebene Routing-Verhalten mit den Abschnitten 2.2 und 2.4 von RFC 3986. Die Arbeit ist abgeschlossen, wenn das Projekt eine Einigung über eine präzise Klarstellung erzielt hat, wie percentkodierte Pfadkomponenten behandelt werden sollen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
api, backend, documentation
Issue-Typ
Dokumentation
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.