-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #69477 ext/zip: Allow extracting to paths with dirs ending with dot #6624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Test failure on Windows:
|
Thanks @nikic for sharing. This was mentioned in https://bugs.php.net/bug.php?id=69477 comment by cmb@php.net as well:
I don't know if there is some kind of policy for these cases. Should we somehow try and replace the dot with underscore or something like that? Are you able to test how Windows unzip handles archives with paths like this? Suggestions welcome. TIA. |
Hmm, googling for "windows folder ending with dot" shows this seems to be a common known issue on Windows ... |
Probably @cmb69 can suggest some appropriate behavior. |
Windows explorer just swallows trailing dots when extracting; 7-zip replaces each dot with an underscore. I think I'd prefer the 7-zip behavior. |
31f7450
to
6313fca
Compare
Thank you in advance for re-evaluation. |
The patch looks good to me from the Windows side. It might make sense to add a test for a drive relative path (something like Anyhow, it seems this PR fixes #77214 as well (that actually appears to be a duplicate of #69477). @remicollet, what do you think about this PR? |
The function `php_zip_make_relative_path()` used to stop on the first right-most occurrence of './' in the ZIP entry path. As a result, the `extractTo()` method didn't extract entries like `foo/bar./baz/file.txt` into correct location.
There are known issues with folder and files ending with dot on Windows. Similarly to how 7-zip deals with the situation, replace the trailing dot with underscore for such files.
If the colon sign is used in a drive relative path (such as C:temp/file.txt), only the part following the colon should be used as the filename.
6313fca
to
d172596
Compare
Good catch @cmb69 on drive relative paths. It turned out they were not handled correctly, only absolute paths were. I added a commit to handle that special case as well. From what I understood, the colon sign is not actually allowed character in file names on Windows at all. So there is still potential for troubles - such as colons at the end or in the middle of path - that were not and are not handled well. Maybe we should replace them with underscores on Windows, too? |
If so, would a new issue be more appropriate rather than trying to fix it here as well? |
There are more characters which are not allowed as filenames on NTFS systems, namely redirection symbols ( |
Thanks @cmb69. I think so. With regards to the failing MACOS_DEBUG_NTS it seems like a failure on the CI infrastructure rather than something actually broken in the patch? Is there something more I am supposed to do here? (sorry to eventually dump question, this is my first contribution here). |
Yes, the macOS failure is unlikely to be related to this patch. This PR is currently waiting on review from Remi, who's got the week off. |
Uh, sorry, completely forgot about this patch. We landed a security fix recently, so this patch has now merge conflicts. I also just submitted PR #7528 (which should solve the colon issues). With these two commits, I think this patch can be massively simplified. However, it is probably a good idea to address the unsupported character issue on Windows first, so I've filed https://bugs.php.net/81488, and forwarded as feature request to libzip. So I think it's best not to do any character replacements in this PR. If you still want to work on this, please adapt the PR accordingly. |
Closing as stale. |
The function
php_zip_make_relative_path()
used to stop on the firstright-most occurrence of './' in the ZIP entry path. As a result, the
extractTo()
method didn't extract entries likefoo/bar./baz/file.txt
into correct location.