Skip to content

Commit dd9f5ba

Browse files
committed
Fix escaped characters in quoted property selectors.
1 parent b98342a commit dd9f5ba

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
## Version 0.3.0 (unreleased)
44

5-
**Features**
6-
75
- Added support for function extensions.
86
- Added the built-in `length()` function.
97
- Added the built-in `count()` function. `count()` is an alias for `length()`
108
- Added the built-in `keys()` function.
119
- Support filters without parentheses.
10+
- Adhere to IETF JSONPath draft escaping in quoted property selectors.
1211

1312
## Version 0.2.0
1413

jsonpath/parse.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""The default JSONPath parser."""
22
from __future__ import annotations
33

4+
import codecs
45
import re
56
from typing import TYPE_CHECKING
67
from typing import Callable
@@ -302,8 +303,10 @@ def parse_selector_list(self, stream: TokenStream) -> ListSelector:
302303
PropertySelector(
303304
env=self.env,
304305
token=stream.current,
305-
name=stream.current.value,
306-
)
306+
name=codecs.decode(
307+
stream.current.value.replace("\\/", "/"), "unicode-escape"
308+
),
309+
),
307310
)
308311
elif stream.current.kind == TOKEN_SLICE_START:
309312
list_items.append(self.parse_slice(stream))

tests/compliance.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,11 @@ def mangle_filter(case: Case) -> Case:
5959
case.selector = case.selector.replace("$[?", "$.*[?")
6060
return case
6161

62-
# TODO: skipping "escaped" test cases for now.
6362
# XXX: skipping filter functions. Not supported.
6463
return [
6564
mangle_filter(case)
6665
for case in cases()
67-
if not case.invalid_selector
68-
and "escaped" not in case.name
69-
and "function" not in case.name
66+
if not case.invalid_selector and "function" not in case.name
7067
]
7168

7269

0 commit comments

Comments
 (0)