summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Watkins <krakjoe@php.net>2017-01-06 05:40:08 +0000
committerJoe Watkins <krakjoe@php.net>2017-01-06 05:40:41 +0000
commit3f89aec7169a095fc9d6dce4a94c726923a577f0 (patch)
tree4445801d5f35fb31ed24cc2670b8ae2ddcb0f1e8
parenta1ff6e72018d1e7de7ce9bd2902a2c7b77b7e240 (diff)
parenta49aaf9ab08af0d61addabe6bce92c61893820df (diff)
downloadphp-git-3f89aec7169a095fc9d6dce4a94c726923a577f0.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fix #70103: ZipArchive::addGlob ignores remove_all_path option news entry for PR #1430
-rw-r--r--NEWS3
-rw-r--r--ext/zip/php_zip.c4
-rw-r--r--ext/zip/tests/bug70103.phpt34
3 files changed, 39 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 3c8a4cf830..3c37416288 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,9 @@ PHP NEWS
- Phar:
. Fixed bug #70417 (PharData::compress() doesn't close temp file). (cmb)
+- ZIP:
+ . Fixed bug #70103 (ZipArchive::addGlob ignores remove_all_path option). (cmb)
+
19 Jan 2017, PHP 7.1.1
- Core:
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 18009e8cdc..5fcd3afc63 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 0000000000..7744532cfa
--- /dev/null
+++ b/ext/zip/tests/bug70103.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Bug #70103 (ZipArchive::addGlob ignores remove_all_path option)
+--SKIPIF--
+<?php
+if (!extension_loaded('zip')) die('skip zip support not available');
+?>
+--FILE--
+<?php
+$dir = __DIR__ . '/bug70103';
+
+mkdir($dir); chmod($dir, 0777);
+file_put_contents($dir . '/foo.txt', 'foo');
+
+$zip = new ZipArchive();
+$zip->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--
+<?php
+$dir = __DIR__ . '/bug70103';
+unlink($dir . '/foo.txt');
+unlink($dir . '/test.zip');
+rmdir($dir);
+?>
+--EXPECT--
+int(1)
+string(7) "foo.txt"