Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON parser decodes escapes in selectors #34

Open
glyn opened this issue Apr 21, 2023 · 2 comments
Open

JSON parser decodes escapes in selectors #34

glyn opened this issue Apr 21, 2023 · 2 comments

Comments

@glyn
Copy link
Contributor

glyn commented Apr 21, 2023

@akshaymankar raised the following issue:

Hi, I finally found time to work on [making jsonpath-hs pass the CTS]. I think the cts.json needs to double escape all the tests [with] selectors which encode characters using the \u notation. Otherwise the JSON parser which parses the test already decodes them giving no chance to the jsonpath parser.

@gregsdennis
Copy link
Collaborator

gregsdennis commented Apr 21, 2023

Are we talking about updating

{
  "name": "name selector, double quotes, embedded U+0000",
  "selector": "$[\"\u0000\"]",
  "invalid_selector": true
}

to

{
  "name": "name selector, double quotes, embedded U+0000",
  "selector": "$[\"\\u0000\"]",
  "invalid_selector": true
}

That means the un-JSON'd path is $["\u0000"] instead of $[""] (which isn't rendered here but should have a 0-char in the string). Do we want to test both, maybe?

These tests, specifically, are supposed to be invalid as we required those chars to be escaped, but I don't see tests where we check the results of paths that do properly escape them.

@glyn
Copy link
Contributor Author

glyn commented Apr 22, 2023

Yes, I think we need to test both those situations. If we don't already, we should also test the use of a Unicode escape in a query to represent a character that is not escaped in the JSON.

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

No branches or pull requests

2 participants