Skip to content

Conversation

@angela-tarantula
Copy link

Fixes #63

Use re.fullmatch instead of re.match to forbid indices with leading zeros in order to be RFC6901-compliant.

Before:

>>> from jsonpointer import JsonPointer
>>> JsonPointer("/array/01").resolve({"array": [1,2,3]})
2

After:

>>> from jsonpointer import JsonPointer
>>> JsonPointer("/array/01").resolve({"array": [1,2,3]})
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    JsonPointer("/array/01").resolve({"array": [1,2,3]})
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/python-json-pointer/jsonpointer.py", line 190, in resolve
    doc = self.walk(doc, part)
  File "/python-json-pointer/jsonpointer.py", line 255, in walk
    part = JsonPointer.get_part(doc, part)
  File "/python-json-pointer/jsonpointer.py", line 234, in get_part
    raise JsonPointerException("'%s' is not a valid sequence index" % part)
jsonpointer.JsonPointerException: '01' is not a valid sequence index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Invalid Array Index Validation in python-json-pointer

1 participant