Skip to content

[MSHARED-815] Sanitize newlines in manifest entry values#363

Open
elharo wants to merge 2 commits into
apache:masterfrom
elharo:master
Open

[MSHARED-815] Sanitize newlines in manifest entry values#363
elharo wants to merge 2 commits into
apache:masterfrom
elharo:master

Conversation

@elharo

@elharo elharo commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #362

Newlines (\n, \r\n, \r) in manifest entry values can produce invalid
MANIFEST.MF files, particularly when empty lines create section separators.
Replace all newline characters with spaces before storing values in manifest
attributes.

Applies sanitization in both addManifestAttribute() (for main manifest
attributes) and the manifest section entries loop.

Includes a test verifying newlines are replaced via getManifest()
(in-memory) and a test verifying the JAR output with empty-line values
remains readable (no manifest corruption).

Newlines (\\n, \\r\\n, \\r) in manifest entry values can produce
invalid MANIFEST.MF files, particularly when empty lines create
section separators. Replace all newline characters with spaces
before storing values in manifest attributes.

Applies sanitization in both addManifestAttribute() (for main
manifest attributes) and the manifest section entries loop.

Fixes apache#362
@elharo elharo changed the title MSHARED-815: Sanitize newlines in manifest entry values [MSHARED-815] Sanitize newlines in manifest entry values Jul 2, 2026
Simplified the addManifestAttribute method by removing unnecessary conditional checks for empty values.
@elharo elharo requested a review from slawekjaranowski July 2, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Newlines are not handled properly in manifest entries created by maven-jar-plugin

1 participant