JSON Pointer lookup accepts malformed tilde escapes in object keys
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 47/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- python
研究方向
Start with Resolver.lookup and the mapping branch that decodes ~1 and ~0; compare its behavior with RFC 6901 section 3. Check the existing resolution exception types and tests for Resolver.lookup and Resource.pointer. Done means malformed escapes such as ~2 and trailing ~ fail resolution while correctly escaped forms such as ~02 still succeed; the issue leaves the exception choice open.
由索引模型根據 Issue 內容生成。
描述
Resolver.lookup accepts malformed JSON Pointer tilde escapes when a matching object key exists. For example, ~2 and a trailing ~ are treated as literal key text rather than an invalid pointer.
from referencing import Registry
from referencing.jsonschema import DRAFT202012
resource = DRAFT202012.create_resource({
"$defs": {"~2": {"type": "integer"}, "~": {"type": "string"}},
})
resolver = Registry().resolver_with_root(resource)
print(resolver.lookup("#/$defs/~2").contents) # {'type': 'integer'}
print(resolver.lookup("#/$defs/~").contents) # {'type': 'string'}
# The correctly escaped forms work too:
print(resolver.lookup("#/$defs/~02").contents) # {'type': 'integer'}
print(resolver.lookup("#/$defs/~0").contents) # {'type': 'string'}
RFC 6901 section 3 permits only ~0 and ~1 as escapes and defines invalid syntax as an error condition. Section 7 leaves the error-handling mechanism to the application. I would expect the first two lookups to fail resolution; the correctly escaped forms should continue to succeed.
Reproduced on main at 45e3c7f0b8191f6f433417d26a59e1e2857f0fcb, Python 3.13.17, macOS ARM64, attrs 26.1.0 and rpds-py 2026.6.3. A local matrix checked six valid and six invalid fragments through both Resolver.lookup and Resource.pointer: all valid controls resolved, but all invalid fragments resolved too. This includes a~b, ~0~ and percent-encoded %7E2; ~01 and ~00 were valid controls to preserve decoding order.
The existing suite, including its pinned referencing-suite submodule, passed locally: 503 passed, 132 xfailed and 406 subtests passed. These are baseline results, not tests of a fix.
The mapping branch currently replaces ~1 and ~0 without validating the token first. I checked #387 and #427: those concern array indices; #444 concerns traversal into scalar values. This report concerns object-key escape syntax and does not propose taking over those patches.
Is rejecting malformed escapes the intended behavior, and should it use an existing resolution exception or a distinct syntax error? I have not prepared a production patch pending that API/compatibility decision. This was found through local code inspection, not a production incident; no security impact is claimed.
OpenAI Codex (GPT-6) assisted with investigation, local reproduction and drafting.
- 主要語言
- Python
- 星號
- 56
- 分支
- 55
- 平均合併
- 6 天 7 小時
- 30 天內合併 PR
- 5
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python-jsonschema/referencing 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 75/100
python-jsonschema/referencing#444 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 68/100
python-jsonschema/referencing#434 ·
-
$ref resolution in a $dynamicRef target ($dynamicAnchor) happening from base URI instead of target未關閉
難度 4/5 3-5 天 新手友好度 30/100
python-jsonschema/referencing#445 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 52/100
python-jsonschema/referencing#442 ·
-
$dynamicRef doesn't find $dynamicAnchor overrides in root schemas without $id可能已有人在做 @aqeelat 於 175 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 45/100
python-jsonschema/referencing#366 ·
查看 python-jsonschema/referencing 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choice可能已有人在做 @beartester34 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 84/100
modelscope/evalscope#2330 ·
維護者通常 1 天內回覆
-
Distribution plot crashes when a numeric feature is constant in the train or test set可能已有人在做 @adembilge 今天認領。 未關閉bug good first issue
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 10 天內回覆
-
難度 1/5 1-3 小時 新手友好度 85/100
維護者通常 2 天內回覆
-
namespace team:operations
難度 2/5 1-3 小時 新手友好度 60/100
EclipseFdn/open-vsx.org#16738 ·
維護者通常 1 天內回覆