Add UNIX file type bits when only permissions are given - #969
Open
maximilliangrand wants to merge 1 commit into
Open
Add UNIX file type bits when only permissions are given#969maximilliangrand wants to merge 1 commit into
maximilliangrand wants to merge 1 commit into
Conversation
When unixPermissions is set to a bare permission value without the
S_IFMT file type bits (e.g. the documented "755" example), the
generated entry stored a mode with no file type, which tools that
inspect the UNIX file type (zipinfo, ...) report as an unknown type
("?rwxr-xr-x"). Fill in the regular-file / directory type bits in that
case, matching the default JSZip already uses when no permissions are
supplied. A mode that already carries a file type (e.g. a 0120777
symlink) is left untouched.
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.
Bug
Setting
unixPermissionsto a bare permission value - the"755"form shown in JSZip's own docs - writes an entry whose UNIX mode has no file-type bits:Cause
generateUnixExternalFileAttr()only fills in the file-type bits (S_IFMT) in its default branch, when no permissions are supplied (0100664/040775). A user-supplied value is written through unchanged, so a bare0755ends up with file-type0. The default path and the user path therefore produce different-quality output.Fix
When permissions are given but the S_IFMT bits are absent, add the regular-file / directory type, matching the default JSZip already uses. A value that already carries a file type (e.g. a
0120777symlink, per #428) is left untouched.Evidence
zipinfoon the same input after the fix:-rwxr-xr-x script.sh,drwxr-xr-x dir/,lrwxrwxrwx link(symlink type preserved). Added a round-trip test inpermissions.js; it fails onmain(755vs100755) and passes with the fix. Lint clean.