Skip to content

Add tests verifying empty lines in manifest values are sanitized - #392

Merged
elharo merged 1 commit into
masterfrom
test/mshared-815-empty-line-verification
Aug 25, 2026
Merged

elharo merged 1 commit into
masterfrom
test/mshared-815-empty-line-verification

Conversation

@elharo

@elharo elharo commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

The fix for MSHARED-815 (commit f2135b1) already sanitizes newlines in manifest entry values. The existing tests cover single \n and \r\n but not multiple consecutive empty lines or bare CR sequences.

Added two tests that verify the fix handles these edge cases:

  • manifestEntryWithMultipleEmptyLinesDoesNotCorruptSubsequentEntries -- verifies that values with multiple \n\n empty lines are sanitized and subsequent manifest entries remain readable
  • manifestEntryWithCRLFEmptyLinesDoesNotCorruptManifest -- verifies \r\n\r\n and \r\r sequences are sanitized correctly

Both tests write a JAR, read the manifest back, and verify the attributes are correct and the manifest is valid. All 86 tests pass.

Closes #225

MSHARED-815 fixed sanitization of newlines in manifest entry values,
but the existing tests only covered single newlines. Add tests that
verify:

- Multiple consecutive empty lines (\\n\\n) are sanitized and
  subsequent manifest entries remain readable
- CRLF empty lines (\\r\\n\\r\\n) are sanitized correctly
- Bare CR sequences (\\r\\r) are sanitized correctly

These tests confirm that the manifest file produced is valid and
can be read back without IOException.

Closes #225
@elharo elharo added java Pull requests that update Java code maintenance labels Aug 20, 2026
@elharo
elharo merged commit 89d3f0f into master Aug 25, 2026
13 checks passed
@elharo
elharo deleted the test/mshared-815-empty-line-verification branch August 25, 2026 20:34
@github-actions github-actions Bot added this to the 4.0.0-beta-5 milestone Aug 25, 2026
slachiewicz added a commit that referenced this pull request Sep 20, 2026
Backport of f2135b1 (#363) and
89d3f0f (#392) from master. Newlines in a manifest entry value produce an
invalid MANIFEST.MF: an empty line ends the main section and the entries
after it are lost. Replace CR, LF and CRLF with a space before the value is
stored, in the main attributes and in the named sections.
@ascheman ascheman modified the milestones: 4.0.0-beta-5, 4.0.0-beta-6 Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MSHARED-815] Maven Archiver: MavenArchiver.addManifestAttribute does not escape empty lines in value

3 participants