`Resource.pointer` indexes into strings
还没有人认领这个 Issue。
评估
调研方向
从 referencing/_core.py 中的 Resource.pointer 开始,具体是 isinstance(contents, Sequence) 分支;issue 指出了确切的错误检查和预期错误。先用 snippet 复现,然后在修改 string 分支之前,确认该方法中其他地方是如何抛出 PointerToNowhere 的。检查测试套件中现有的 pointer 测试,确定应在哪里添加覆盖:对字符串使用 /name/0 会抛出错误,而不是返回 'x'。完成意味着字符串不再继续向下解析,并且非 mapping、非 sequence 的值会抛出 PointerToNowhere。
由索引模型根据 Issue 内容生成。
描述
Resource.pointer treats any collections.abc.Sequence as a JSON array, and str is a
Sequence, so a pointer can step into a string's characters. RFC 6901 §4 only descends into
objects and arrays, so this reference should not resolve.
from referencing import Registry, Resource
Resource.opaque({"name": "xyz"}).pointer("/name/0", Registry().resolver()).contents
# 'x' (expected: PointerToNowhere)
Reproduced on referencing 0.37.0 (CPython 3.12) and on main at 45e3c7f (CPython 3.13).
The cause is the isinstance(contents, Sequence) branch in Resource.pointer
(referencing/_core.py). The open PRs #387 and #427 validate the array-token spelling inside that
branch, but a string still takes it, so /name/0 resolves with either change applied. Excluding
str from that branch, and raising PointerToNowhere when the current value is neither a mapping
nor a non-string sequence, would fix it.
- 主要语言
- Python
- 星标
- 56
- 派生
- 55
- 平均合并
- 5 天 22 小时
- 30 天内合并 PR
- 4
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-jsonschema/referencing 的其他 Issue
-
难度 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 于 174 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 45/100
python-jsonschema/referencing#366 ·
-
难度 4/5 3-5 天 新手友好度 35/100
python-jsonschema/referencing#257 ·
查看 python-jsonschema/referencing 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 78/100
web-push-libs/pywebpush#216 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
AgriciDaniel/claude-seo#572 ·
维护者通常 5 天内回复
-
area:print-dispatch
难度 2/5 1-3 小时 新手友好度 92/100
维护者通常 1 天内回复
-
area: docs domain: technical-writing good first issue type: documentation
难度 2/5 1-3 小时 新手友好度 80/100
Deepak3699/Ai_Mentor#919 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复