Fix relative-json-pointer rejecting multi-digit integers containing a zero#1503
Open
nyxst4ck wants to merge 1 commit into
Open
Fix relative-json-pointer rejecting multi-digit integers containing a zero#1503nyxst4ck wants to merge 1 commit into
nyxst4ck wants to merge 1 commit into
Conversation
The relative-json-pointer format checker disallowed a leading zero by checking
the *previous* character (int(instance[i - 1]) == 0), so any non-negative
integer prefix containing a 0 followed by another digit -- '100', '205',
'1000', '100/foo', '100#' -- was wrongly rejected. Per
draft-handrews-relative-json-pointer-01 section 3 only a leading zero is
forbidden ('0' alone is valid; '01' is not).
Reject only when the accumulated integer is exactly '0' and another digit
follows.
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
relative-json-pointerformat checker rejects valid pointers whosenon-negative-integer prefix contains a
0after the first digit.The leading-zero guard checked the previous character rather than the first
digit:
So any integer prefix with a
0followed by another digit was wrongly rejected,while the bundled conformance suite only exercises
"120"(where the0islast) and so never caught it:
Per draft-handrews-relative-json-pointer-01 §3, only a leading zero is
forbidden:
"0"by itself is valid,"01"is not, and"100"/"205"/"1000"are valid.Fix
Reject only when the accumulated integer is exactly
"0"and another digitfollows (i.e. a genuine leading zero), instead of rejecting any digit that
follows a
0.Tests
Added
test_relative_json_pointer_allows_multidigit_integerstojsonschema/tests/test_format.py:0/1/120/100/205/1000/100/foo/100#are validand
01/00/007/01/a/01#are not. It fails onmainand passes with the fix.Full
test_format.py+ the JSON Schema test suite stay green (7628 passed);ruffclean.(Happy to add a
CHANGELOG.rstentry if you'd like.)