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.

Bewertung

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

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.

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.

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus python/peps

Alle Issues in python/peps

Ähnliche Issues

Weitere Issues zu Backend & API Design

Neue Issues direkt in Ihr Postfach

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