Convert name selectors and string literals to the string they denote (RFC 9535 2.3.1.2) - #112
Merged
Merged
Conversation
RFC 9535, section 2.3.1.2 converts a name-selector string to a member name by removing the quotes and replacing each escape sequence with the character it names. The parser kept the raw source token instead and left the decoding to whoever consumed it, so six places downstream each did part of the job: normalize_json_key, the quote trimming in Value::get, prepare_regex, convert_js_path, parse_deletion_path and Pointer::key. Decode once in the parser and delete all six. Also accept lower-case hex in \uXXXX, join surrogate pairs, build Normalized Paths per section 2.7 and JSON Pointers per RFC 6901. Against the compliance test suite with filtered_cases.json emptied, failures go from 37 to 13; the 24 that now pass are removed from that file.
Owner
|
thank you for the pr. It looks good |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
$["\t"]finds nothing in{"\t": "A"}while a raw tab in the selector finds it, because the parser keeps the source token of a name selector verbatim and leaves the decoding to whoever consumes it — RFC 9535, section 2.3.1.2 says the string must be converted to a member name by removing the quotes and replacing each escape sequence with the character it names. Six places downstream were each doing part of that job (normalize_json_key, the quote trimming inValue::get,prepare_regex,convert_js_path,parse_deletion_pathandPointer::key), which is also why$['\'']today returns the member named\rather than the one named', and why$["a"]reports its normalized path as$['"a"']. This decodes once in the parser and removes all six;\uXXXXnow also accepts lower-case hex (section 2.3.1.1: the hexadecimal digits "can be either lowercase or uppercase"), surrogate pairs are joined, and normalized paths follow section 2.7 whilereference/delete_by_pathescape their JSON Pointers per RFC 6901.Against the suite in
rfc9535/withfiltered_cases.jsonemptied, failures go from 37 to 13, and the 24 that now pass are exactly the entries I removed from that file; the remaining 11 skips and 2 failures are #86, #87, #91 and the descendant-ordering case, all untouched. That is also why these survived to 1.0.6: the run recorded inresults.csvas703; 666; 2on 2026-07-14 cannot happen in CI, since the CTS is a submodule no job checks out andrfc9535is a binary crate thatcargo nextest runnever executes. I left CI alone — arming it would turn the remaining 13 red, and that is your call.cargo test --all-featuresgoes from 101 to 106 passing, pluscargo fmt --check,cargo clippy --workspace --all-targets --all-features -D warningsandcargo docclean. Five existing tests asserted the old behaviour and are updated:tab_keyandcarr_returnused documents keyed"\\t"and"\\r"(a backslash followed by a letter) where the CTS uses a real tab and CR,literal_testexpectedhel\'lofor'hel\'lo', andname_sel/single_quoteasserted the old un-normalized paths. I also checked the fix is not over-eager: re-adding the\\collapse inprepare_regexbreaks two CTS cases that pass onmain, and escaping non-ASCII in normalized paths breaks yourescaped_up_hexandsurr_pairs.Closes #88, closes #89, closes #90.