Make sure attachment-max-header-size property is respected for repeated and multi-line headers - #3425
Open
reta wants to merge 1 commit into
Open
Make sure attachment-max-header-size property is respected for repeated and multi-line headers#3425reta wants to merge 1 commit into
reta wants to merge 1 commit into
Conversation
…ed and multi-line headers
There was a problem hiding this comment.
Pull request overview
Ensures the attachment-max-header-size limit is enforced consistently when MIME part headers are provided as repeated header fields or as folded (multi-line) headers during attachment deserialization.
Changes:
- Enforce
maxHeaderLengthon unfolded (continued) header lines while accumulating multi-line headers. - Enforce
maxHeaderLengthacross repeated occurrences of the same header name. - Add tests covering single oversized header values, repeated headers exceeding the limit cumulatively, and multi-line headers exceeding the limit when unfolded.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializerUtil.java | Adds max-header-size enforcement for unfolded continuation lines and cumulative repeated-header values. |
| core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java | Adds regression tests for oversized headers across single, repeated, and folded header cases. |
Suppressed comments (2)
core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java:772
- This test assumes the default
attachment-max-header-sizeis 300, but that default is derived from a system property and may differ across environments. SetAttachmentDeserializer.ATTACHMENT_MAX_HEADER_SIZEon the message so the test remains stable and clearly validates the repeated-header sizing behavior.
msg = new MessageImpl();
msg.setContent(InputStream.class, new ByteArrayInputStream(sb.toString().getBytes(StandardCharsets.UTF_8)));
msg.put(Message.CONTENT_TYPE, "multipart/related");
AttachmentDeserializer ad = new AttachmentDeserializer(msg);
core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java:804
- This test’s expected exception depends on the global default
attachment-max-header-size(configurable via system property). To avoid environment-dependent failures and to ensure the property handling is what’s being tested, setAttachmentDeserializer.ATTACHMENT_MAX_HEADER_SIZEexplicitly on the message.
msg = new MessageImpl();
msg.setContent(InputStream.class, new ByteArrayInputStream(sb.toString().getBytes(StandardCharsets.UTF_8)));
msg.put(Message.CONTENT_TYPE, "multipart/related");
AttachmentDeserializer ad = new AttachmentDeserializer(msg);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Make sure
attachment-max-header-sizeproperty is respected for repeated and multi-line headers