PEP 3333: URL-decoding and routing

未關閉
#3,280 3 則留言 7 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
25/100
Issue 類型
文件
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
python

研究方向

首先閱讀 PEP 3333 和連結的 Starlette 討論,然後將其中描述的路由行為與 RFC 3986 第 2.2 和 2.4 節進行比較。當專案就應如何處理百分比編碼的路徑元件達成明確共識後,工作即告完成。

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
reStructuredText
星號
5k
分支
1.8k
平均合併
2 天 4 小時
30 天內合併 PR
25

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

python/peps 的其他 Issue

查看 python/peps 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。