Skip to content

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

Merged
elharo merged 2 commits into
apache:masterfrom
elharo:master
Jul 21, 2026
Merged

[MSHARED-815] Sanitize newlines in manifest entry values#363
elharo merged 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
@elharo
elharo merged commit f2135b1 into apache:master Jul 21, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

@elharo Please assign appropriate label to PR according to the type of change.

@github-actions github-actions Bot added this to the 4.0.0-beta-5 milestone Jul 21, 2026
@elharo elharo added the bug Something isn't working label Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

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

2 participants