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分
- マージ済み PR(30日)
- 2
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
letsencrypt/cp-cps#361 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
CI: startup_failure because callers grant fewer permissions than ledger-app-workflows@v1 declares対応中かも @maykonmichel が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
LedgerHQ/app-boilerplate-rust#227 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
linuxmint/mintupdate#1107 ·