Fix #1640: validate numeric value separator in non-root context for non-blocking parser - #1648
Open
seonwooj0810 wants to merge 1 commit into
Open
Conversation
…ext for non-blocking parser Non-blocking (async) parser did not verify that numeric values are followed by a valid separator (whitespace, comma, `]`, `}`) when parsed inside an Array or Object context, silently accepting inputs like `[123true]` or `[1.5x]` that blocking parsers correctly rejected. Root cause: five inline integer-completion sites in `NonBlockingUtf8JsonParserBase` (`_startPositiveNumber(int)`, `_startNegativeNumber`, `_startPositiveNumber`, `_finishNumberIntegralPart`, hex-number completion) and the float-completion sites in `_startFloat`, `_finishFloatFraction`, `_finishFloatExponent` called `_valueComplete` without a separator check. The blocking-parser fix in FasterXML#1615 added `_verifyNumberSeparator` to the three blocking parsers; this PR applies the equivalent check to the non-blocking path.
Contributor
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.
Summary
Follow-up to #1615 (which fixed the three blocking parsers) and per @cowtowncoder's comment in that PR confirming a separate fix for the non-blocking path is warranted.
The non-blocking (
async) parser did not verify that numeric values are followed by a valid separator (whitespace, comma,],}) when parsed inside an Array or Object context, silently accepting malformed inputs that blocking parsers rejected:Root cause
Five integer-completion sites and three float-completion sites in
NonBlockingUtf8JsonParserBasecalled_valueComplete(JsonToken.VALUE_NUMBER_*)without a separator check:_startPositiveNumber(int ch)— inline digit loop_startNegativeNumber()— inline digit loop_startPositiveNumber()— inline digit loop (+ sign variant)_finishNumberIntegralPart(...)— resumption path (chunk boundary)resetIntHex)_startFloat(...)— inline fraction/exponent loop_finishFloatFraction()— resumption path (fraction digits)_finishFloatExponent(...)— resumption path (exponent digits)Fix
Adds
_verifyNumberSeparator(int ch)toNonBlockingUtf8JsonParserBase, mirroring the same method added to the three blocking parsers in #1615. For root context it delegates to the existing_verifyRootSpace(ch); for non-root context it validates the separator is one of\t\r\n,]}(or a comment-start character if the respective feature is enabled), consistent with the blocking-parser behavior.All 8 completion sites now call
_verifyNumberSeparator(ch)before_valueComplete(...).Testing
AsyncNumberSeparator1640Testcovering int, float-fraction, and float-exponent mangled cases acrossbytesPerReadvalues of 90, 3, and 1 (to exercise both inline and resumption paths).AsyncTokenBranchNumberErrorTest.mangledNonRootIntsintofix/now passes; removed its@JacksonTestFailureExpectedannotation. ThemangledNonRootFloatstest remains intofix/(the 'f'/'d' suffix case still uses a dedicated code path with a different error message).Fixes #1640