[PR #929] [MERGED] Fix zipentry comment implementation #1351

Open
opened 2026-01-29 22:20:07 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/929
Author: @Morilli
Created: 7/19/2025
Status: Merged
Merged: 7/22/2025
Merged by: @adamhathcock

Base: masterHead: fix-zipentry-comment


📝 Commits (2)

  • d78a682 add failing test
  • 4e7baeb fix zipentry comment being lost after reading local entry header

📊 Changes

8 files changed (+23 additions, -12 deletions)

View changed files

📝 src/SharpCompress/Archives/Zip/ZipArchiveEntry.cs (+0 -2)
📝 src/SharpCompress/Common/Zip/Headers/DirectoryEntryHeader.cs (+0 -2)
📝 src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs (+2 -0)
📝 src/SharpCompress/Common/Zip/SeekableZipFilePart.cs (+2 -8)
📝 src/SharpCompress/Common/Zip/SeekableZipHeaderFactory.cs (+5 -0)
📝 src/SharpCompress/Common/Zip/ZipEntry.cs (+2 -0)
📝 tests/SharpCompress.Test/Zip/ZipArchiveTests.cs (+12 -0)
tests/TestArchives/Archives/Zip.EntryComment.zip (+0 -0)

📄 Description

The Comment field was only present the directory entry header, not the local entry header. This makes some sense as the local entry header does not have a comment in the zip file, but due to the way the local entry header was loaded (replacing the directory entry header with the local entry header) this caused the code expecting a directory entry header to fail once that happened.

I've decided to just put the Comment field on the underlying ZipFileEntry class and copy the value from the directory entry header to the local entry header.

See the added test for how this failed.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adamhathcock/sharpcompress/pull/929 **Author:** [@Morilli](https://github.com/Morilli) **Created:** 7/19/2025 **Status:** ✅ Merged **Merged:** 7/22/2025 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `fix-zipentry-comment` --- ### 📝 Commits (2) - [`d78a682`](https://github.com/adamhathcock/sharpcompress/commit/d78a682dd8caf3a7cc9976863f408bd0d4c3f652) add failing test - [`4e7baeb`](https://github.com/adamhathcock/sharpcompress/commit/4e7baeb2c95f2a24938b5a08f4a7762b3ce6b577) fix zipentry comment being lost after reading local entry header ### 📊 Changes **8 files changed** (+23 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `src/SharpCompress/Archives/Zip/ZipArchiveEntry.cs` (+0 -2) 📝 `src/SharpCompress/Common/Zip/Headers/DirectoryEntryHeader.cs` (+0 -2) 📝 `src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs` (+2 -0) 📝 `src/SharpCompress/Common/Zip/SeekableZipFilePart.cs` (+2 -8) 📝 `src/SharpCompress/Common/Zip/SeekableZipHeaderFactory.cs` (+5 -0) 📝 `src/SharpCompress/Common/Zip/ZipEntry.cs` (+2 -0) 📝 `tests/SharpCompress.Test/Zip/ZipArchiveTests.cs` (+12 -0) ➕ `tests/TestArchives/Archives/Zip.EntryComment.zip` (+0 -0) </details> ### 📄 Description The `Comment` field was only present the directory entry header, not the local entry header. This makes some sense as the local entry header does not have a comment in the zip file, but due to the way the local entry header was loaded (replacing the directory entry header with the local entry header) this caused the code expecting a directory entry header to fail once that happened. I've decided to just put the `Comment` field on the underlying `ZipFileEntry` class and copy the value from the directory entry header to the local entry header. See the added test for how this failed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 22:20:07 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1351