Repository navigation
json BUGFIX reject non-hex digits in unicode escapes - #2635
Merged
Merged
Conversation
michalvasko
approved these changes
Nov 18, 2026
Member
|
Thanks, merging into |
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.
lyjson_string()decodes the four digits of a\uXXXXescape without checking that they are hex: digits go through'0', anything above'F'is treated as a lowercase letter and everything else as an uppercase one, with the unsigned math wrapping, and only a NUL was rejected. so any four characters turn into some code point, and whenever it lands in the rangely_pututf8()accepts, the value is stored as a character nobody sent:"\u002s"is stored as<, and"\u004""as+, with the closing quote eaten as the last digit so the string keeps running into the JSON text after it. RFC 8259 wants four HEXDIGs and python's json module rejects both, so a RESTCONF body or anydata content can be tokenized differently by libyang than by whatever looked at it first. the hex character reference path inlyxml_parse_value()already guards this withisxdigit(), so the fix does the same here and reuses the existing error; the new cases intest_stringfail on the current tree.