fix: strip file-type bits from ZIP external_attributes in list -l output#90
Merged
fix: strip file-type bits from ZIP external_attributes in list -l output#90
Conversation
ZIP archives created by Unix tools store the full stat(2) mode in external_attributes (e.g. 0o100644 = S_IFREG|0o644, 0o040755 = S_IFDIR|0o755). The zip crate's unix_mode() returns external_attributes >> 16, which includes these file-type bits. ArchiveEntry.mode now masks the value with 0o7777 so that only permission bits are stored, matching the output of TAR entries. Fixes #80
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.
Summary
list -ldisplayed raw Unix file-type bits for ZIP entries (e.g.100644instead of644) becauseZipFile::unix_mode()returnsexternal_attributes >> 16, which includesS_IFREG/S_IFDIRbits from archives created by external Unix tools& 0o7777when storing it inArchiveEntry.mode, keeping only the permission bits — matching the behavior of TAR entriesTest plan
test_zip_mode_strips_s_ifreg_bits: crafts a raw ZIP with0o100644inexternal_attributes, verifiesmode = Some(0o644)test_zip_mode_strips_s_ifdir_bits: crafts a raw ZIP with0o040755, verifiesmode = Some(0o755)test_zip_mode_permission_bits_unchanged: permission-only value preserved after maskingtest_tar_and_zip_mode_consistent: TAR0o644and ZIP0o100644produce identicalArchiveEntry.modeFixes #80