php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77978 Dirname ending in colon unzips to wrong dir
Submitted: 2019-05-07 08:08 UTC Modified: 2019-05-21 20:01 UTC
From: lars at larsegon dot se Assigned: santiagolizardo (profile)
Status: Assigned Package: Zip Related
PHP Version: 7.3.5 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
46 - 34 = ?
Subscribe to this entry?

 
 [2019-05-07 08:08 UTC] lars at larsegon dot se
Description:
------------
If a directory name in a path for a file in zip archive ends with a colon (:) the file will be extracted to the root dir instead of to its original directory.

Test script:
---------------
<?php

$file = tempnam("/tmp", "ziptest");
$target = tempnam("/tmp", "ziptest");
unlink($target);
mkdir($target);

$zip = new ZipArchive;
$zip->open($file);
$zip->addFromString("dir/test:/filename.txt", "contents");
$zip->addFromString("dir/test:a/filename.txt", "contents");
$zip->addFromString("dir/test/filename.txt", "contents");
$zip->close();

$zip->open($file);
$zip->extractTo($target, "dir/test:/filename.txt");
$zip->extractTo($target, "dir/test:a/filename.txt");
$zip->extractTo($target, "dir/test/filename.txt");
$zip->close();

unlink($file);



Expected result:
----------------
Expected behavior would be that the three files were extracted to the following paths:
/tmp/ziptest/dir/test:/filename.txt
/tmp/ziptest/dir/test:a/filename.txt
/tmp/ziptest/dir/test/filename.txt

Actual result:
--------------
If you run the test script, three files will be extracted to the following paths:
/tmp/ziptest/filename.txt
/tmp/ziptest/dir/test:a/filename.txt
/tmp/ziptest/dir/test/filename.txt

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-21 20:01 UTC] santiagolizardo@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: santiagolizardo
 [2019-05-25 01:34 UTC] konstantin dot kuklin at gmail dot com
The following pull request has been associated:

Patch Name: Fixed bug #77978
On GitHub:  https://github.com/php/php-src/pull/4160
Patch:      https://github.com/php/php-src/pull/4160.patch
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 11:01:25 2019 UTC