Ne-Lexa / php-zip

PhpZip is a php-library for extended work with ZIP-archives.
MIT License
491 stars 60 forks source link

Handle directory symlinks properly. #75

Open parhuzamos opened 3 years ago

parhuzamos commented 3 years ago
Q A
Bug fix? yes
New feature? no

As symlinks are special files in the zip, symlinks to directories must be treated like files and must loose their directory attribute. Those zip entries may not have / as a suffix in their name, as ZipEntry->setName() would mark them as a directory.

Note that PHP treats symlinks as files, so FilesUtil::removeDir() had to be modified too for the test to pass.

$ php -r 'chdir(exec("mktemp -d")); mkdir("one"); symlink("./one", "symlinked"); rmdir("one"); rmdir("symlinked"); unlink("symlinked");'

Produces: PHP Warning: rmdir(symlinked): Not a directory in Command line code on line 1 But unlink() succeeds.