Repository navigation
Accept an escaped single quote in JSON5 strings - #138
Merged
Merged
Conversation
JSON5 allows \' in both single- and double-quoted strings, but neither escape switch had a case for it, so 'a\'b' failed with invalid_string_escape_sequence under allow_json5. Accept it when single- quoted strings are allowed, and keep rejecting it otherwise, as JSON does.
Owner
|
Good catch! |
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.
JSON5 allows
\'in strings (it is listed with the other single-character escapes in the spec), but neither escape switch has a case for it:json5['a\'b']allow_json5/allow_single_quoted_strings["a'b"]["a'b"]["c\'d"]["c'd"]["c'd"]["c\'d"]This accepts
\'injson_get_string_sizewhenallow_single_quoted_stringsis set (it is part ofallow_json5) and writes a'for it injson_parse_string. Without the flag it is stillinvalid_string_escape_sequence.escaped_single_quoteandescaped_single_quote_without_flagfollow the otherallow_single_quoted_stringstests; the first fails on main. Accepting it regardless of the flag fails the second, and writing the wrong character fails the first. The suite passes in gcc Debug and Release builds and in a Debug build with ASan and UBSan; I did not run clang, tcc or MSVC.Written with AI assistance (Claude); I have reviewed the change.