Bug #77978 [Opn->Ver]: Dirname ending in colon unzips to wrong dir

From: Date: Tue, 28 Sep 2021 20:27:05 +0000
Subject: Bug #77978 [Opn->Ver]: Dirname ending in colon unzips to wrong dir
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236905@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77978&edit=1

 ID:                 77978
 Updated by:         cmb@php.net
 Reported by:        lars at larsegon dot se
 Summary:            Dirname ending in colon unzips to wrong dir
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            Zip Related
 Operating System:   Linux
 PHP Version:        7.3.5
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2019-10-20 11:22:43] ctrujillopineda 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/4835
Patch:      https://github.com/php/php-src/pull/4835.patch

------------------------------------------------------------------------
[2019-05-25 01:34:31] 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

------------------------------------------------------------------------
[2019-05-07 08:08:57] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=77978&edit=1


Thread (8 messages)

« previous php.bugs (#236905) next »