mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.3'
* PHP-8.3: NEWS NEWS fix GH-12661 (Inconsistency in ZipArchive::addGlob remove_path Option Behavior)
This commit is contained in:
commit
6cbb075ffa
2 changed files with 26 additions and 1 deletions
|
@ -1772,7 +1772,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
|
|||
basename = php_basename(Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file), NULL, 0);
|
||||
file_stripped = ZSTR_VAL(basename);
|
||||
file_stripped_len = ZSTR_LEN(basename);
|
||||
} else if (opts.remove_path && strstr(Z_STRVAL_P(zval_file), opts.remove_path) != NULL) {
|
||||
} else if (opts.remove_path && !memcmp(Z_STRVAL_P(zval_file), opts.remove_path, opts.remove_path_len)) {
|
||||
if (IS_SLASH(Z_STRVAL_P(zval_file)[opts.remove_path_len])) {
|
||||
file_stripped = Z_STRVAL_P(zval_file) + opts.remove_path_len + 1;
|
||||
file_stripped_len = Z_STRLEN_P(zval_file) - opts.remove_path_len - 1;
|
||||
|
|
25
ext/zip/tests/bug_gh12661.phpt
Normal file
25
ext/zip/tests/bug_gh12661.phpt
Normal file
|
@ -0,0 +1,25 @@
|
|||
--TEST--
|
||||
Bug GH-12661 (Inconsistency in ZipArchive::addGlob 'remove_path' Option Behavior)
|
||||
--EXTENSIONS--
|
||||
zip
|
||||
--FILE--
|
||||
<?php
|
||||
include __DIR__ . '/utils.inc';
|
||||
|
||||
touch($file = __DIR__ . '/bug_gh12661.zip');
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||
$zip->addGlob(__FILE__, 0, ['remove_path' => 'bug_']); // unchanged (bug is not a prefix)
|
||||
$zip->addGlob(__FILE__, 0, ['remove_path' => dirname(__DIR__)]);
|
||||
verify_entries($zip, [__FILE__, basename(__DIR__) . DIRECTORY_SEPARATOR . basename(__FILE__)]);
|
||||
$zip->close();
|
||||
|
||||
?>
|
||||
Done
|
||||
--CLEAN--
|
||||
<?php
|
||||
unlink(__DIR__ . '/bug_gh12661.zip');
|
||||
?>
|
||||
--EXPECT--
|
||||
Done
|
Loading…
Add table
Add a link
Reference in a new issue