bug77978.phpt 968 B

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