Bug #67996 [Opn->Nab]: ZipArchive stores and extracts parent directories
| From: | ab@php.net | Date: | Fri, 12 Sep 2014 08:59:52 +0000 |
| Subject: | Bug #67996 [Opn->Nab]: ZipArchive stores and extracts parent directories | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187524@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67996&edit=1
ID: 67996
Updated by: ab@php.net
Reported by: petrhudecek2010 at gmail dot com
Summary: ZipArchive stores and extracts parent directories
-Status: Open
+Status: Not a bug
Type: Bug
Package: Zip Related
Operating System: Windows 8.1
PHP Version: 5.5.16
Block user comment: N
Private report: N
New Comment:
That's what I read in http://www.pkware.com/documents/casestudies/APPNOTE.TXT
chapter 4.4.17:
"4.4.17.1 The name of the file, with optional relative path.
The path stored MUST not contain a drive or
device letter, or a leading slash. All slashes
MUST be forward slashes '/' as opposed to
backwards slashes '\' for compatibility with Amiga
and UNIX file systems etc. If input came from standard
input, there is no file name field. "
Thus the current behavior is valid. You can use chdir() to achieve the result you've described.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2014-09-10 12:51:12] petrhudecek2010 at gmail dot com
Description:
------------
You may use ZipArchive->addEmptyDir to add a folder in a parent directory without renaming it.
You can then extract using ZipArchive and the folder will be recreated in the parent folders of the
destination.
Test script:
---------------
<?php
$archive = new ZipArchive();
$archive->open('a.zip',ZipArchive::CREATE);
$archive->addEmptyDir("../../down");
$archive->close();
$archive2 = new ZipArchive();
$archive2->open('a.zip');
$archive2->extractTo('.');
$archive2->close();
Expected result:
----------------
During creation:
An error. The ZIP file should not be created.
During extraction:
It should silently succeed. The folder "down" should not be created.
Actual result:
--------------
The file "a.zip" was created. During extraction, the folder "down" was created
in the grandfather directory.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67996&edit=1