Prefix modifier crashes on non-string values; reserved expansion stops encoding once the value contains a percent-escape
まだ誰も着手していません。
評価
調査の方向性
uritemplate/variable.pyから始めます。issueでは、プレフィックスの処理と予約展開のクォート処理の経路が指摘されています。RFC 6570の該当セクションを読み、{var:N}、{+var}、{#var}を対象とするテストを見つけます。文字列以外のプレフィックス値と、安全でない文字が混在するパーセントエスケープについて回帰テストを追加します。両方のケースがRFCに従って展開されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Two related problems in uritemplate/variable.py, reproduced on 4.2.0 (main 8e46228).
1. {var:N} with an int or float value raises TypeError
>>> from uritemplate import expand
>>> expand("{a:1}", {"a": 12})
TypeError: 'int' object is not subscriptable
>>> expand("{a}", {"a": 12})
'12'
Non-string scalars are accepted everywhere else (they are converted with str() in Operator.quote), but the prefix is applied before that conversion: value = value[:prefix] if prefix else value. Converting first (str(value)[:prefix]) fixes it; RFC 6570 §2.4.1 defines the prefix on the string form of the value.
2. Reserved (+) and fragment (#) expansion leave unsafe characters unencoded if the value contains any %XX
>>> from uritemplate import expand
>>> expand("{+a}", {"a": "a b"})
'a%20b'
>>> expand("{+a}", {"a": "a b%41"})
'a b%41' # expected 'a%20b%41'
Operator._only_quote_unquoted_characters returns the value unchanged whenever unquote(value) != value, so one pre-existing percent-escape disables encoding for the whole string, including the space. RFC 6570 §3.2.3 says reserved expansion keeps existing pct-encoded triplets and encodes everything else that is not in reserved/unreserved; the check needs to be per character (or per triplet), not per string.
Happy to send a PR with tests for both if you would take one.
- 主要言語
- Python
- スター
- 246
- フォーク
- 41
- 平均マージ
- 8時間 20分
- マージ済み PR(30日)
- 3
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-hyper/uritemplate のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
python-hyper/uritemplate#164 · コメント 2 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
python-hyper/uritemplate#51 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
python-hyper/uritemplate#34 · コメント 4 件 ·
-
Provide an API for validating URI Templates対応中かも @sigmavirus24 が 3381 日前に担当しました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
python-hyper/uritemplate#33 · コメント 9 件 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
python-hyper/uritemplate#15 ·
python-hyper/uritemplate の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
WLAN-Pi/wlanpi-profiler#341 ·
メンテナーはふだん 1 日以内に返信
-
Memory leak: the shared `validation_aborted_error` keeps every traceback it is raised through対応中かも @Fire162 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
graphql-python/graphql-core#287 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
roman-corgi/ctc-dip#160 ·
メンテナーはふだん 1 日以内に返信
-
type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
render_findings.py reads and writes in the host's default encoding, so findings.html breaks on a cp1252 Windows host対応中かも @Aaqibhafeezkhan が今日担当しました。 オープンbug good first issue mentored python size: XS up-for-grabs
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
dheerajjha/mcp-migrate#366 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信