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:12
Avg. Score:4.2 ± 0.8
Reproduced:12 of 12 (100.0%)
Same Version:5 (41.7%)
Same OS:4 (33.3%)
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jason at opengeek dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

Pull requests:

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
 [2021-01-14 19:00 UTC] david at moodle dot com
I just commented in #77214 with the explanation of the bug.
 [2021-01-19 18:01 UTC] david at moodle dot com
The following pull request has been associated:

Patch Name: Fix #69477 ext/zip: Allow extracting to paths with dirs ending with dot
On GitHub:  https://github.com/php/php-src/pull/6624
Patch:      https://github.com/php/php-src/pull/6624.patch
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 09:01:33 2024 UTC