xref: /PHP-7.4/ext/zip/tests/bug77978.phpt (revision e0c0de00)
1--TEST--
2Bug #77978 (Dirname ending in colon unzips to wrong dir)
3--SKIPIF--
4<?php
5if (!extension_loaded("zip")) die("skip zip extension not available");
6?>
7--FILE--
8<?php
9$file = __DIR__ . "/bug77978.zip";
10$target = __DIR__ . "/bug77978";
11
12mkdir($target);
13
14$zip = new ZipArchive();
15$zip->open($file, ZipArchive::CREATE|ZipArchive::OVERWRITE);
16$zip->addFromString("dir/test:/filename.txt", "contents");
17$zip->close();
18
19$zip->open($file);
20// Windows won't extract filenames with colons; we suppress the warning
21@$zip->extractTo($target, "dir/test:/filename.txt");
22$zip->close();
23
24var_dump(!file_exists("$target/filename.txt"));
25var_dump(PHP_OS_FAMILY === "Windows" || file_exists("$target/dir/test:/filename.txt"));
26?>
27--EXPECT--
28bool(true)
29bool(true)
30--CLEAN--
31<?php
32@unlink(__DIR__ . "/bug77978.zip");
33@unlink(__DIR__ . "/bug77978/dir/test:/filename.txt");
34@rmdir(__DIR__ . "/bug77978/dir/test:");
35@rmdir(__DIR__ . "/bug77978/dir");
36@rmdir(__DIR__ . "/bug77978");
37?>
38