Repository navigation
THRIFT-6462: Decode JSON escapes above U+7FFF in the JavaME TJSONProtocol - #4061
Merged
Merged
Conversation
…ocol Client: javame readJSONString assembled the four hex digits of an escape into a short, so the escapes of U+8000 to U+FFFF became negative code units. The surrogate branches cast the value back to char, but the plain-character branch passed it to toUTF8(int), which wrote only the low byte, and the string read back with a different character. Keep the code unit as a char, as the Java library does since THRIFT-4408. TestJSONUnicodeEscapes reads the escapes of characters below and above U+8000, a surrogate pair, and escapes between plain characters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
THRIFT-6462
readJSONStringinlib/javame/src/org/apache/thrift/protocol/TJSONProtocol.javaassembled the four hex digits of an escape into ashort, so the escapes of U+8000 to U+FFFF became negative code units. The surrogate branches cast the value back tocharand decoded pairs correctly. The plain-character branch, however, passed the negative value totoUTF8(int), which wrote only its low byte. The read did not fail; the string came back with a different character.This change keeps the code unit as a
char, as the Java library does since THRIFT-4408 (bd3ba6f).New test
lib/javame/test/TestJSONUnicodeEscapes.java, which thelib-javameCI job runs with the othertest/Test*.java:The tests were built and run the way the
lib-javamejob runs them (JDK 17,thrift:jammy): all five lib/javame tests pass. On master the new test fails 6 of 12 checks.🤖 Generated with Claude Code