Repository navigation
Conversation
wylovelyi
force-pushed
the
fix-issue-7809
branch
from
November 4, 2026 03:41
7203816 to
8359de0
Compare
JSONReaderASCII.readFieldName() reads bytes[offset + 1] to decide the escape length, but the loop only guards offset < end. A backslash as the final byte read past the array and leaked ArrayIndexOutOfBoundsException instead of the documented JSONException. Guard the lookahead, and report the same "invalid escape character EOI" message as the UTF8/UTF16 readers. Fixes alibaba#7809
wylovelyi
force-pushed
the
fix-issue-7809
branch
from
November 4, 2026 04:39
8359de0 to
d7bdc68
Compare
This branch has not been deployed
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.
What this PR does / why we need it?
JSONReaderASCII.readFieldName()throwsArrayIndexOutOfBoundsExceptionfor a field name that ends with a backslash:The loop guard only covers
bytes[offset], while the escape branch readsbytes[offset + 1]to decide the skip length. When the backslash is the final byte,offset + 1 == end.This is the same defect class as #7914 (bound reads on truncated numbers, comments and field names). #7914 fixed the two whitespace loops in this method, but not this lookahead. Its description mentions that #7810 no longer reproduces; #7809 still does on current main (
35111f33).Summary of your change
JSONReaderASCII.readFieldName()and raiseJSONException, consistent with the existing malformed-name handling.byteAfterEscape/charAfterEscapepluscheckEscapeEnd, so only the ASCII reader needs this guard. Escaped field names are unaffected.Validation
Issue7809covers backslash-terminated field names through both input paths:{"\,{"a\and{"a":1,"b\asString, and{"\/{"a\as UTF-8 bytes. The 8-, 9- and 10-character cases also exercise thenameValue0/nameValue1fast paths inreadFieldName().{"a\"b":1},{"a\\b":1},{"a\u0041b":1},{"a\tb":1},{"abcdefgh":1}through{"abcdefghij":1}(bothStringand bytes), plus normal{"a":1}and{}../mvnw -pl core -Dtest=Issue7809 testpasses on JDK 17.Fixes #7809
Please indicate you've done the following: