php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69477 ZipArchive::extractTo() truncates path segments ending in .
Submitted: 2015-04-17 19:12 UTC Modified: 2015-04-18 01:02 UTC
Votes:11
Avg. Score:4.2 ± 0.8
Reproduced:11 of 11 (100.0%)
Same Version:5 (45.5%)
Same OS:4 (36.4%)
From: jason at opengeek dot com Assigned:
Status: Open Package: Zip Related
PHP Version: 5.6.8 OS: OS X 10.10.3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-04-17 19:12 UTC] jason at opengeek dot com
Description:
------------
ZipArchive::extractTo will truncate any path segment which ends in a period. For instance, if I create a zip file and add the file `path/to./file.txt` and then extract that file, it will be extracted to `path//file.txt` instead of in the actual expected path.

See the gist provided for a sample script which demonstrates the problem.

Test script:
---------------
https://gist.github.com/opengeek/483d830bf35b60a2ef22

Expected result:
----------------
/usr/local/bin/php /Users/opengeek/repos/test/test-zip.php
Opened archive test-archive.zip successfully
test/test.txt
test./test.txt
.test/test.txt

Process finished with exit code 0

Actual result:
--------------
/usr/local/bin/php /Users/opengeek/repos/test/test-zip.php
Opened archive test-archive.zip successfully
test/test.txt
test./test.txt
.test/test.txt
Extract failure: expected file extracted to test-extract/test./text.txt

Process finished with exit code 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-17 19:51 UTC] elizabeth at modx dot com
Same thing happening on 5.4:

$ php t.php
Opened archive test-archive.zip successfully
test/test.txt
test./test.txt
.test/test.txt
Extract failure: expected file to exist at test-extract/test./text.txt
$ php -v
PHP 5.4.30 (cli) (built: Jun 27 2014 12:05:12)
 [2015-04-18 01:02 UTC] cmb@php.net
FWIW: Windows doesn't like trailing dots in folder names, so such
archives would not be portable.
 [2018-08-05 04:14 UTC] carusogabriel@php.net
Related to Bug #74619
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 22:01:24 2019 UTC