diff options
author | Stefan Kögl <stefan@skoegl.net> | 2017-10-28 12:46:41 +0200 |
---|---|---|
committer | Stefan Kögl <stefan@skoegl.net> | 2017-10-29 22:44:25 +0100 |
commit | 0d30f12f3f64dbe58bd816597856fb34d9e31fcd (patch) | |
tree | 83ca1f3013e4db5b7ce073da43a2729427ffc5af /jsonpointer.py | |
parent | ba2af26490f16d1e4f7bf57791af2ade8e90fcb7 (diff) | |
download | python-json-pointer-0d30f12f3f64dbe58bd816597856fb34d9e31fcd.tar.gz |
Perform input validation in JsonPoinervalidation
Diffstat (limited to 'jsonpointer.py')
-rw-r--r-- | jsonpointer.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/jsonpointer.py b/jsonpointer.py index 097627f..fd54569 100644 --- a/jsonpointer.py +++ b/jsonpointer.py @@ -167,8 +167,16 @@ class JsonPointer(object): # Array indices must not contain: # leading zeros, signs, spaces, decimals, etc _RE_ARRAY_INDEX = re.compile('0|[1-9][0-9]*$') + _RE_INVALID_ESCAPE = re.compile('(~[^01]|~$)') def __init__(self, pointer): + + # validate escapes + invalid_escape = self._RE_INVALID_ESCAPE.search(pointer) + if invalid_escape: + raise JsonPointerException('Found invalid escape {0}'.format( + invalid_escape.group())) + parts = pointer.split('/') if parts.pop(0) != '': raise JsonPointerException('location must starts with /') |