To encode or not encode - best practices for "uncommon" uri characters, including whitespaces (%20)?
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 30/100
- Issue 類型
- 缺陷
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- python
- 領域
- networking
研究方向
使用 rfc3986.builder.URIBuilder.from_uri、extend_path 和 finalize 重現這些範例,比較初始 URI 中的空白與傳遞給 extend_path 的空白。檢查 issue 中連結的 RFC 3986 章節,並確定兩條建構路徑是否應產生相同的百分比編碼結果;確定預期行為並透過回歸測試涵蓋後,即視為完成。
由索引模型根據 Issue 內容生成。
描述
Dear all,
I am currently struggeling with a whitespace problem which I guess should not be that complicated - so I probably missing something here.
MWE:
import rfc3986.builder
rfc3986.builder.URIBuilder.from_uri("scheme:").extend_path("path 1").extend_path("path2").geturl()
# outout: 'scheme:/path 1/path2'
rfc3986.builder.URIBuilder.from_uri("scheme:").extend_path("path 1/path2").geturl()
# outout: 'scheme:/path 1/path2'
rfc3986.builder.URIBuilder.from_uri("scheme:path 1").extend_path("path2").geturl()
# outout: 'scheme:/path%201/path2'
therefore: If i am having a whitespace in the from_uri-part, it gets escaped by %20, whereby having the whitespace as part of the parameter to extend_path, it gets used as is.
From the broader scope, I am storing URIs in a database which get constructed on one component "from scratch" (containing whitespaces ...), whereas they are passed in a url-encoded - conformant manner in another component.
I already figured out that there is an equivalence when passing maybe-url-encoded strings to from_uri:
from_uri_a=rfc3986.builder.URIBuilder.from_uri("scheme:/path 1/path2").finalize()
from_uri_b=rfc3986.builder.URIBuilder.from_uri("scheme:/path%201/path2").finalize()
from_uri_a == from_uri_b
# is True
My main goal is to store the URIs in a future-proof way in my database and from the requirements I am having it does not really make a big difference whether or not I am storing the URLs encoded or not - but from the broader scope I am unsure whether the current implementation is desired or not (aka. a bug or a feature).
From the rfc, sec. 2.4, I guess that an encoding should take place in the extend_path method:
Under normal circumstances, the only time when octets within a URI
are percent-encoded is during the process of producing the URI from
its component parts. This is when an implementation determines which
of the reserved characters are to be used as subcomponent delimiters
and which can be safely used as data. Once produced, a URI is always
in its percent-encoded form.
Any thoughts on this?
- 主要語言
- Python
- 星號
- 189
- 分支
- 43
- 平均合併
- 12 小時 14 分鐘
- 30 天內合併 PR
- 2
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python-hyper/rfc3986 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 86/100
python-hyper/rfc3986#164 ·
-
ParseResultBytes.unsplit() raises AttributeError for a reference without an authority可能已有人在做 @mayuriphad 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 84/100
python-hyper/rfc3986#163 ·
-
難度 3/5 1-2 天 新手友好度 45/100
python-hyper/rfc3986#138 · 1 則留言 ·
-
sdist is missing `tox.ini`可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 2/5 1-3 小時 新手友好度 55/100
python-hyper/rfc3986#129 ·
-
wrong parse未關閉
難度 3/5 1-2 天 新手友好度 38/100
python-hyper/rfc3986#128 ·
查看 python-hyper/rfc3986 的全部 Issue
相似的 Issue
-
link-rot
難度 1/5 1 小時以內 新手友好度 67/100
-
難度 2/5 1-3 小時 新手友好度 82/100
developmentseed/titiler-cmr#265 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
Insecure Brotli version <1.2.1可能已有人在做 @jamescw19 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 85/100
stac-utils/stac-fastapi-pgstac#438 · 1 個 reaction ·
-
bug triage
難度 2/5 1-3 小時 新手友好度 66/100
維護者通常 1 天內回覆