diff --git a/NEWS b/NEWS index 46bba01f1cdcd..6520d887eda4e 100644 --- a/NEWS +++ b/NEWS @@ -103,4 +103,7 @@ PHP NEWS - XMLRPC: . Use Zend MM for allocation in bundled libxmlrpc (Joe) +- ZIP: + . Fixed bug #70103 (ZipArchive::addGlob ignores remove_all_path option). (cmb) + <<< NOTE: Insert NEWS from last stable release here prior to actual release! >>> diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 2651ac499b062..706ae07a3d51b 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1704,8 +1704,8 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* entry_name = entry_name_buf; entry_name_len = strlen(entry_name); } else { - entry_name = Z_STRVAL_P(zval_file); - entry_name_len = Z_STRLEN_P(zval_file); + entry_name = file_stripped; + entry_name_len = file_stripped_len; } if (basename) { zend_string_release(basename); diff --git a/ext/zip/tests/bug70103.phpt b/ext/zip/tests/bug70103.phpt new file mode 100644 index 0000000000000..7744532cfa069 --- /dev/null +++ b/ext/zip/tests/bug70103.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #70103 (ZipArchive::addGlob ignores remove_all_path option) +--SKIPIF-- + +--FILE-- +open($dir . '/test.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE); +$zip->addGlob($dir . '/*.txt', GLOB_NOSORT, array('remove_all_path' => true)); +$zip->close(); + +$zip = new ZipArchive(); +$zip->open($dir . '/test.zip'); +var_dump($zip->numFiles); +var_dump($zip->getNameIndex(0)); +$zip->close(); +?> +--CLEAN-- + +--EXPECT-- +int(1) +string(7) "foo.txt"