Repository navigation
JRuby: keep the whole character after an invalid escape - #1081
Merged
Merged
Conversation
With allow_invalid_escape, the JRuby decoder appended the code point read after a stray backslash with append(int), which writes only its low byte. "\\é" became "\xE9" and "\\あ" became "B", where the C extension keeps the character. Use writeUtf8Char, as the other code point paths do.
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.
With
allow_invalid_escape: true, the JRuby decoder keeps the character after a stray backslash withappend(character), which writes only the low byte of the code point (StringDecoder.java:158). The C extension keeps the character's bytes.Switched to
writeUtf8Char, and added a case next totest_parse_invalid_escape, which only covers ASCII. Onjruby:9.4-jdk21,bundle exec rake test JSON_COMPACT=1fails the new test on master and passes with the change (591 tests); CRuby already passes it.Written with AI assistance (Claude); I ran the tests above locally and reviewed the change.