JSON Pointer lookup accepts malformed tilde escapes in object keys
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 47/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- backend-api-design
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 56
- Fork
- 55
- Merge medio
- 6g 7h
- PR unite (30g)
- 5
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python-jsonschema/referencing
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
python-jsonschema/referencing#444 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
python-jsonschema/referencing#434 ·
-
$ref resolution in a $dynamicRef target ($dynamicAnchor) happening from base URI instead of targetAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
python-jsonschema/referencing#445 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
python-jsonschema/referencing#442 ·
-
$dynamicRef doesn't find $dynamicAnchor overrides in root schemas without $idForse già presa @aqeelat l’ha presa 175 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
python-jsonschema/referencing#366 ·
Tutte le issue di python-jsonschema/referencing
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choiceForse già presa @beartester34 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
modelscope/evalscope#2330 ·
I maintainer di solito rispondono entro 1 giorno
-
Distribution plot crashes when a numeric feature is constant in the train or test setForse già presa @adembilge l’ha presa oggi. Apertabug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
MAIF/shapash#847 · 1 commento ·
I maintainer di solito rispondono entro 10 giorni
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
namespace team:operations
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
EclipseFdn/open-vsx.org#16738 ·
I maintainer di solito rispondono entro 1 giorno