Repository navigation
FILEUPLOAD-369: Accept transport padding after a multipart boundary d… - #486
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
…elimiter RFC 2046, section 5.1.1 allows a delimiter to be followed by transport padding (SP and HTAB) and requires a receiver to handle it. The parser only accepted a delimiter directly followed by CRLF or "--". Padding after the first delimiter made the body look as if it had no parts, and padding after any later delimiter caused a MalformedStreamException. Skip the padding after the delimiter.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the boundary transport-padding change.
No open issues 🎉
What changed in this PR
Addresses FILEUPLOAD-369 by allowing MultipartStream to handle boundary transport padding as required by RFC 2046.
Changes:
- Skips spaces and horizontal tabs after a boundary while still rejecting padding before the closing
--marker. - Adds regression tests for unpadded boundaries, padded first, intermediate, and closing delimiters, and invalid padding placement.
| File | Description |
|---|---|
src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java |
Adds a parsing helper and boundary-padding regression tests. |
src/main/java/org/apache/commons/fileupload/MultipartStream.java |
Handles transport padding and preserves closing-marker validation. |
Review effort: Balanced
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.
RFC 2046, section 5.1.1 allows a delimiter to be followed by transport padding (SP and HTAB) and requires a receiver to be able to handle it.
MultipartStream.readBoundary()only accepted a delimiter directly followed by CRLF or "--". Padding after the first delimiter made the body look as if it had no parts, and padding after any later delimiter caused aMalformedStreamException.The padding is now skipped after the delimiter. It is still not accepted before the "--" of the close delimiter, since the RFC only allows it after the complete delimiter.
The new tests in
MultipartStreamTestcover padding after the first, a later and the close delimiter, and padding before the close marker. Two of them fail without the change.mvn -B -ntppasses (92 tests, checkstyle).JIRA: https://issues.apache.org/jira/browse/FILEUPLOAD-369
The same code exists in the copy of this class kept in Apache Tomcat, where the maintainers asked for the fix to be made here first.