Reject trailing characters in DecimalLocaleConverter.parse (1.X)#400
Merged
garydgregory merged 1 commit intoJun 21, 2026
Merged
Conversation
DecimalFormat.parse(String) stops at the first unparsable character and drops the rest, so the locale numeric converters accepted trailing garbage (123abc -> 123, '42 OR 1=1' -> 42). Every numeric locale converter routes through DecimalLocaleConverter.parse, while the sibling DateLocaleConverter already rejects leftover input via a ParsePosition check. Switch to the same form and throw ParseException unless the whole string is consumed. Port of the 2.x fix to the 1.X branch. Updates the now-stale (B) assertions across the numeric locale converter tests, which pinned the old partial-parse values and now fall through to the converter default.
7 tasks
garydgregory
added a commit
that referenced
this pull request
Jun 21, 2026
Member
|
Thank you @rootvector2 , merged 🚀 |
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.
Port of #399 to the
1.Xbranch.DecimalLocaleConverter.parsecallsDecimalFormat.parse(String), which stops at the first character it cannot read and silently drops the rest, so a locale numeric conversion of123abcreturns123and42 OR 1=1returns42. Every numeric locale converter (Byte/Short/Integer/Long/Float/Double/BigDecimal/BigInteger) routes through this one method, while the siblingDateLocaleConverteralready rejects leftover input with aParsePositioncheck. Switched to that same form so the whole string must be consumed, otherwiseParseExceptionis thrown.Added
DecimalLocaleConverterTest(fails without the runtime change) and updated the now-stale(B)assertions across the numeric locale converter tests, which pinnedDecimalFormat's old partial-parse values and now fall through to the converter default.mvn test -Dtest='*LocaleConverterTest'is green (104 tests). The only failure in a fullmvnrun isLocaleBeanificationTest.testContextClassloaderIndependence, which is a pre-existing flake unrelated to this change (it fails the same way on a clean1.Xcheckout and installs its own mock converters that bypass real parsing).mvn; that'smvnon the command line by itself.