mirror of
https://github.com/php/php-src.git
synced 2026-04-17 21:11:02 +02:00
When making the relative path, we must not stop on a `:\` sequence in the middle of the filename. This is only significant on Windows as it may indicate an absolute filename, but this is already checked at the beginning of the function. Note that the bug and this patch affects all systems. However, on Windows the file is no longer extracted at all, since Windows NTSF does not allow filenames containing colons. Closes GH-7528.
38 lines
968 B
PHP
38 lines
968 B
PHP
--TEST--
|
|
Bug #77978 (Dirname ending in colon unzips to wrong dir)
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded("zip")) die("skip zip extension not available");
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
$file = __DIR__ . "/bug77978.zip";
|
|
$target = __DIR__ . "/bug77978";
|
|
|
|
mkdir($target);
|
|
|
|
$zip = new ZipArchive();
|
|
$zip->open($file, ZipArchive::CREATE|ZipArchive::OVERWRITE);
|
|
$zip->addFromString("dir/test:/filename.txt", "contents");
|
|
$zip->close();
|
|
|
|
$zip->open($file);
|
|
// Windows won't extract filenames with colons; we suppress the warning
|
|
@$zip->extractTo($target, "dir/test:/filename.txt");
|
|
$zip->close();
|
|
|
|
var_dump(!file_exists("$target/filename.txt"));
|
|
var_dump(PHP_OS_FAMILY === "Windows" || file_exists("$target/dir/test:/filename.txt"));
|
|
?>
|
|
--EXPECT--
|
|
bool(true)
|
|
bool(true)
|
|
--CLEAN--
|
|
<?php
|
|
@unlink(__DIR__ . "/bug77978.zip");
|
|
@unlink(__DIR__ . "/bug77978/dir/test:/filename.txt");
|
|
@rmdir(__DIR__ . "/bug77978/dir/test:");
|
|
@rmdir(__DIR__ . "/bug77978/dir");
|
|
@rmdir(__DIR__ . "/bug77978");
|
|
?>
|