diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index f7cfcee57c1..43d8d27d564 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -105,8 +105,8 @@ static char * php_zip_make_relative_path(char *path, size_t path_len) /* {{{ */ return path; } - if (i >= 2 && (path[i -1] == '.' || path[i -1] == ':')) { - /* i is the position of . or :, add 1 for / */ + if (i >= 2 && path[i -1] == '.') { + /* i is the position of ., add 1 for / */ path_begin = path + i + 1; break; } diff --git a/ext/zip/tests/bug77978.phpt b/ext/zip/tests/bug77978.phpt new file mode 100644 index 00000000000..2f3c22f4213 --- /dev/null +++ b/ext/zip/tests/bug77978.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #77978 (Dirname ending in colon unzips to wrong dir) +--SKIPIF-- + +--FILE-- +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-- +