Repository navigation
Conversation
During constructor binding, DataBinder.getIndexes() and createMap() look
for the closing bracket of a parameter name such as "list[0]" or
"map[key]" and use the result of indexOf(']') without checking it. A
request parameter whose name is missing the bracket, such as "list[35"
or "map[key", therefore fails with a StringIndexOutOfBoundsException, and
the request ends with a 500 error instead of the parameter being ignored.
Skip such names, as is already done for other names that do not match
the indexed form.
Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
sbrannen
requested changes
Nov 19, 2026
sbrannen
left a comment
Member
There was a problem hiding this comment.
Hi @Marti2203,
Thanks for the PR. The change looks good.
However, a non-numeric or out-of-range index (for example, integerList[abc] or integerList[99999999999]) still causes an uncaught NumberFormatException in getIndexes(), which also results in a 500 error.
Since that's the same kind of problem in the same method, please ignore such names as well and add a test for that scenario.
Thanks
An index that Integer.parseInt() rejects, such as integerList[abc] or integerList[99999999999], threw a NumberFormatException from getIndexes(). Skip such parameter names, as for an index without a closing bracket. Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
Author
|
Thanks. Done in 091e06e: an index that |
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.
During constructor binding,
DataBinder.getIndexes()andcreateMap()look for the closing bracket of a parameter name such aslist[0]ormap[key], and use the result ofindexOf(']')without checking it. A request parameter whose name lacks the bracket, for examplea[35for a record or constructor-bound bean with anaparameter ofList, array orMaptype, therefore fails with:and the request ends with a 500 error. This is the same code as gh-34121, which fixed the
list[]form (no index) but not a name without the closing bracket.This change skips such names, as is already done for other names that do not match the indexed form. Two new tests,
DataBinderConstructTests.simpleListBindingIgnoresUnclosedIndexandsimpleMapBindingIgnoresUnclosedKey, fail before the change and pass after it.Testing:
DataBinderConstructTests(30 tests),DataBinderTests(94) andDataBinderFieldAccessTests(9),:spring-context:checkstyleMainandcheckstyleTestpass. 7.0.x and 6.2.x have the same code.The issue was found by an LLM-assisted tool and verified manually.