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