Add tests for invalid surrogate pairs #87
Merged
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.
Adds tests for invalid surrogate pairs, and one test for directly using a character > U+FFFF (
𝄞
) in the selector, instead of escaping it.Note: Another interesting test would be
"selector": "$[\"\\uD800\uDC00\"]"
(for this a JSONPath implementation might erroneously first convert
\\uD800
to U+D800 before performing validation, and then consider this a valid surrogate pair)"selector": "$[\"\uD800\uD800\"]"
Note in both cases the single
\
instead of\\
.Both are not permitted by JSONPath because it says the query must be valid UTF-8, which is not the case here.
However, it depends on the programming language whether such malformed surrogate pairs are possible. For example for Java whose strings are UTF-16 based such selectors would be valid strings, but the JSONPath implementation would have to reject them.
The problem is that for other programming languages such strings are not valid (e.g. Rust uses UTF-8 for strings), so including for example
"selector": "$[\"\\uD800\uDC00\"]"
might prevent a Rust library from loadingcts.json
at all. Therefore such tests can probably not be added.