Skip to content

Commit 7166662

Browse files
committed
Handle UTF-16 surrogate pairs in quoted property selectors.
1 parent dd9f5ba commit 7166662

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
## Version 0.3.0 (unreleased)
44

5+
**IETF JSONPath Draft compliance**
6+
57
- Added support for function extensions.
68
- Added the built-in `length()` function.
79
- Added the built-in `count()` function. `count()` is an alias for `length()`
8-
- Added the built-in `keys()` function.
10+
- Added the built-in `keys()` function (non-standard).
911
- Support filters without parentheses.
1012
- Adhere to IETF JSONPath draft escaping in quoted property selectors.
13+
- Handle UTF-16 surrogate pairs in quoted property selectors.
1114

1215
## Version 0.2.0
1316

jsonpath/parse.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ def parse_selector_list(self, stream: TokenStream) -> ListSelector:
305305
token=stream.current,
306306
name=codecs.decode(
307307
stream.current.value.replace("\\/", "/"), "unicode-escape"
308-
),
308+
)
309+
.encode("utf-16", "surrogatepass")
310+
.decode("utf-16"),
309311
),
310312
)
311313
elif stream.current.kind == TOKEN_SLICE_START:

tests/compliance.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ class Case:
3333

3434

3535
SKIP = {
36-
"name selector, double quotes, surrogate pair 𝄞": "TODO",
37-
"name selector, double quotes, surrogate pair 😀": "TODO",
38-
"name selector, single quotes, surrogate pair 𝄞": "TODO",
39-
"name selector, single quotes, surrogate pair 😀": "TODO",
4036
"filter, nested": "not supported",
4137
}
4238

@@ -59,7 +55,7 @@ def mangle_filter(case: Case) -> Case:
5955
case.selector = case.selector.replace("$[?", "$.*[?")
6056
return case
6157

62-
# XXX: skipping filter functions. Not supported.
58+
# TODO: skipping filter functions. Not supported.
6359
return [
6460
mangle_filter(case)
6561
for case in cases()

0 commit comments

Comments
 (0)