Repository navigation
WW-5874 Bound memory used for multipart form fields by struts.multipart.maxStringLength - #2161
Open
shadowe1ite wants to merge 1 commit into
Open
shadowe1ite wants to merge 1 commit into
shadowe1ite wants to merge 1 commit into
Conversation
lukaszlenart
requested changes
Dec 3, 2026
Member
There was a problem hiding this comment.
Thanks for the patch. I ran the multipart and upload tests on this branch (JakartaStreamMultiPartRequestTest, JakartaMultiPartRequestTest, ActionFileUploadInterceptorTest), all green, and checked the boundary cases by hand: a field of exactly maxStringLength characters is accepted, one character more is rejected with the real length in the message, and supplementary characters are still counted as two chars, as before.
Three small things before this can go in, details inline:
- the one-argument
readStreamis left without a production caller, - the new protected method needs Javadoc with
@since, - the commit headline needs the
WW-5874prefix, the same as the PR title.
We will carry the matching change to support/struts-6-x-x ourselves once this is merged, so there is nothing for you to do on that branch.
…rt.maxStringLength
shadowe1ite
force-pushed
the
fix/multipart-max-string-length
branch
from
December 3, 2026 11:01
f702283 to
a120316
Compare
Author
|
@lukaszlenart Thanks for the review! Fixed the issues you flagged. |
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.
Fixes WW-5874
JakartaStreamMultiPartRequestread every form field fully into aByteArrayOutputStreamand built the wholeStringbefore checkingmaxStringLength. So withmaxStringLength=10, a 100 KB field was still buffered in full.The field is now decoded as it's read and only up to
maxStringLengthcharacters are kept. The rest of the part is still read so the error can report the real length, but it isn't buffered. The limit is still counted in characters, so multibyte input behaves the same as before.exceedsMaxStringLength(String, long)is added toAbstractMultiPartRequest, and the existingStringoverload calls it, so subclasses aren't affected.Tests cover a 100,000 character field with a limit of 10, multibyte input, and an end to end
parse()check that the field is dropped and the error reports the real length. They fail without the fix; all multipart and upload tests in core pass with it.