mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #80863: ZipArchive::extractTo() ignores references
This commit is contained in:
commit
cc86f70de9
2 changed files with 45 additions and 2 deletions
|
@ -2728,7 +2728,6 @@ PHP_METHOD(ZipArchive, extractTo)
|
|||
zend_string *files_str = NULL;
|
||||
HashTable *files_ht = NULL;
|
||||
|
||||
zval *zval_file = NULL;
|
||||
php_stream_statbuf ssb;
|
||||
char *pathto;
|
||||
size_t pathto_len;
|
||||
|
@ -2765,7 +2764,8 @@ PHP_METHOD(ZipArchive, extractTo)
|
|||
RETURN_FALSE;
|
||||
}
|
||||
for (i = 0; i < nelems; i++) {
|
||||
if ((zval_file = zend_hash_index_find(files_ht, i)) != NULL) {
|
||||
zval *zval_file;
|
||||
if ((zval_file = zend_hash_index_find_deref(Z_ARRVAL_P(zval_files), i)) != NULL) {
|
||||
switch (Z_TYPE_P(zval_file)) {
|
||||
case IS_LONG:
|
||||
break;
|
||||
|
|
43
ext/zip/tests/bug80863.phpt
Normal file
43
ext/zip/tests/bug80863.phpt
Normal file
|
@ -0,0 +1,43 @@
|
|||
--TEST--
|
||||
Bug #80863 (ZipArchive::extractTo() ignores references)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('zip')) die("skip zip extension not available");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$archive = __DIR__ . "/bug80863.zip";
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($archive, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||
$zip->addFromString("file1.txt", "contents");
|
||||
$zip->addFromString("file2.txt", "contents");
|
||||
$zip->close();
|
||||
|
||||
$target = __DIR__ . "/bug80683";
|
||||
mkdir($target);
|
||||
|
||||
$files = [
|
||||
"file1.txt",
|
||||
"file2.txt",
|
||||
];
|
||||
// turn into references
|
||||
foreach ($files as &$file);
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($archive);
|
||||
$zip->extractTo($target, $files);
|
||||
var_dump(is_file("$target/file1.txt"));
|
||||
var_dump(is_file("$target/file2.txt"));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
--CLEAN--
|
||||
<?php
|
||||
@unlink(__DIR__ . "/bug80863.zip");
|
||||
$target = __DIR__ . "/bug80683";
|
||||
@unlink("$target/file1.txt");
|
||||
@unlink("$target/file2.txt");
|
||||
@rmdir($target);
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue