Bug #77978 [NEW]: Dirname ending in colon unzips to wrong dir

From: Date: Tue, 07 May 2019 08:08:57 +0000
Subject: Bug #77978 [NEW]: Dirname ending in colon unzips to wrong dir
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220723@lists.php.net to get a copy of this message
From:             lars at larsegon dot se
Operating system: Linux
PHP version:      7.3.5
Package:          Zip Related
Bug Type:         Bug
Bug description:Dirname ending in colon unzips to wrong dir

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 bug report at https://bugs.php.net/bug.php?id=77978&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=77978&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=77978&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=77978&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=77978&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=77978&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=77978&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=77978&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=77978&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=77978&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=77978&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=77978&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=77978&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=77978&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77978&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=77978&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=77978&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=77978&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77978&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=77978&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=77978&r=mysqlcfg



Thread (8 messages)

« previous php.bugs (#220723) next »