. Changed functions to accept/return XMKWriter objects instead of resources.
(cmb)
+- Zip:
+ . Fixed bug #72374 (remove_path strips first char of filename). (tyage)
+
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>
. The XMLWriter functions now accept and return, respectively, XMLWriter
objects instead of resources.
+- Zip:
+ . The remove_path option of ZipArchive::addGlob() and ::addPattern() is now
+ treated as arbitrary string prefix (for consistency with the add_path
+ option), whereas formerly it was treated as directory name. This means that
+ if no trailing directory separator is given, the following character is
+ no longer stripped from the filename.
+
- Zlib:
. gzgetss() has been removed.
size_t real_len = strlen(remove_path);
if ((real_len > 1) && ((remove_path[real_len - 1] == '/') || (remove_path[real_len - 1] == '\\'))) {
remove_path[real_len - 1] = '\0';
+ remove_path_len -= 1;
}
}
file_stripped = ZSTR_VAL(basename);
file_stripped_len = ZSTR_LEN(basename);
} else if (remove_path && strstr(Z_STRVAL_P(zval_file), remove_path) != NULL) {
- file_stripped = Z_STRVAL_P(zval_file) + remove_path_len + 1;
- file_stripped_len = Z_STRLEN_P(zval_file) - remove_path_len - 1;
+ file_stripped = Z_STRVAL_P(zval_file) + remove_path_len;
+ file_stripped_len = Z_STRLEN_P(zval_file) - remove_path_len;
} else {
file_stripped = Z_STRVAL_P(zval_file);
file_stripped_len = Z_STRLEN_P(zval_file);
--- /dev/null
+--TEST--
+Bug #72374 (ZipArchive::addGlob remove_path option strips first char of filename)
+--SKIPIF--
+<?php
+if(!extension_loaded('zip')) die('skip');
+?>
+--FILE--
+<?php
+$dirname = dirname(__FILE__) . '/';
+include $dirname . 'utils.inc';
+
+$dirname = $dirname . 'bug72374/';
+mkdir($dirname);
+$file = $dirname . 'some-foo.txt';
+touch($file);
+
+$zip = new ZipArchive();
+$zip->open($dirname . 'test.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
+$zip->addGlob($file, 0, array('remove_path' => $dirname . 'some-'));
+$zip->addGlob($file, 0, array('remove_path' => $dirname));
+verify_entries($zip, ['foo.txt', '/some-foo.txt']);
+$zip->close();
+?>
+--CLEAN--
+<?php
+$dirname = dirname(__FILE__) . '/';
+include $dirname . 'utils.inc';
+
+$dirname = $dirname . 'bug72374/';
+rmdir_rf($dirname);
+?>
+--EXPECT--
exit('failed');
}
$dir = realpath($dirname);
-$options = array('add_path' => 'baz/', 'remove_path' => $dir);
+$options = array('add_path' => 'baz', 'remove_path' => $dir);
if (!$zip->addPattern('/\.txt$/', $dir, $options)) {
echo "failed\n";
}
"foobar/",
"foobar/baz",
"entry1.txt",
- "baz/foo.txt",
- "baz/bar.txt"
+ "baz" . DIRECTORY_SEPARATOR . "foo.txt",
+ "baz" . DIRECTORY_SEPARATOR . "bar.txt"
])) {
echo "failed\n";
} else {