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 于 4 天前认领。 未关闭
难度 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`可能已有人在做 @ketpatil77 今天认领。 未关闭
难度 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
-
follow-up
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
modelscope/modelscope#1833 ·
维护者通常 1 天内回复
-
ocr_data_to_elements() raises AttributeError when a layout element is a List可能已有人在做 @Eapp1e 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 79/100
Unstructured-IO/unstructured#4616 ·
维护者通常 1 天内回复