|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77214 ZipArchive::extractTo() errors on directories ending with .
Submitted: 2018-11-28 16:21 UTC Modified: 2018-11-28 19:19 UTC
From: nystrom dot lars dot egon at gmail dot com Assigned:
Status: Verified Package: Zip Related
PHP Version: 7.2.12 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-11-28 16:21 UTC] nystrom dot lars dot egon at gmail dot com
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;
// Next line causes the error if the zip file contains a directory named 'myfolder.'
$zip->extractTo($extractPath, ['myfolder.']); 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-28 19:19 UTC]
-Status: Open +Status: Verified
 [2018-11-28 19:19 UTC]
I get this error message if the archive contains an *empty*
directory entry with a trailing dot.  Test script:


    $zip = new ZipArchive;
    $zip->open(__DIR__ . '/', ZipArchive::CREATE | ZipArchive::OVERWRITE);

    $zip->open(__DIR__ . '/');
    $zip->extractTo(__DIR__ . '/77214');

The culprit is php_zip_make_relative_path()[1], which mistakenly
returns an empty string instead of "foo."

[1] <>
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 23 18:01:30 2019 UTC