Bug #77214 [Opn->Ver]: ZipArchive::extractTo() errors on directories ending with .

From: Date: Wed, 28 Nov 2018 19:19:30 +0000
Subject: Bug #77214 [Opn->Ver]: ZipArchive::extractTo() errors on directories ending with .
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218188@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77214&edit=1 ID: 77214 Updated by: cmb@php.net Reported by: nystrom dot lars dot egon at gmail dot com Summary: ZipArchive::extractTo() errors on directories ending with . -Status: Open +Status: Verified Type: Bug Package: Zip Related Operating System: Linux PHP Version: 7.2.12 Block user comment: N Private report: N New Comment: I get this error message if the archive contains an *empty* directory entry with a trailing dot. Test script: <?php $zip = new ZipArchive; $zip->open(__DIR__ . '/77214.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE); $zip->addEmptyDir('foo.'); $zip->close(); $zip->open(__DIR__ . '/77214.zip'); $zip->extractTo(__DIR__ . '/77214'); $zip->close(); The culprit is php_zip_make_relative_path()[1], which mistakenly returns an empty string instead of "foo." [1] <https://github.com/php/php-src/blob/php-7.3.0RC6/ext/zip/php_zip.c#L115-L130> Previous Comments: ------------------------------------------------------------------------ [2018-11-28 16:21:19] nystrom dot lars dot egon at gmail dot com Description: ------------ This is closely related to bug #69477, but I'm experiencing a different behavior. When you have a zip archive that contains a directory with a name that ends with . (a dot) ZipArchive errors out with the message: ZipArchive::extractTo(/path/to/extract/to/): failed to open stream: Is a directory Test script: --------------- $extractPath = "/path/to/extract/to"; $zip = new ZipArchive; $zip->open("/path/to/zipfile"); // Next line causes the error if the zip file contains a directory named 'myfolder.' $zip->extractTo($extractPath, ['myfolder.']); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77214&edit=1

« previous php.bugs (#218188) next »