1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4'

* PHP-8.4:
  Fix GH-17201: Dom\TokenList issues with interned string replace
This commit is contained in:
Niels Dossche
2024-12-17 23:08:11 +01:00
2 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
--TEST--
GH-17201 (Dom\TokenList issues with interned string replace)
--EXTENSIONS--
dom
--INI--
opcache.protect_memory=1
--FILE--
<?php
$dom = DOM\XMLDocument::createFromString('<root class="AA B C"/>');
$element = $dom->documentElement;
$list = $element->classList;
$list->replace('AA', 'AB'); // Use interned string
foreach ($list as $entry) {
var_dump($entry);
}
?>
--EXPECT--
string(2) "AB"
string(1) "B"
string(1) "C"

View File

@@ -583,7 +583,8 @@ PHP_METHOD(Dom_TokenList, replace)
/* It already exists, remove token instead. */
zend_hash_del_bucket(token_set, bucket);
} else {
Z_STR(bucket->val) = new_token;
/* Need to use ZVAL_STR instead of Z_STR to reset the type flags. */
ZVAL_STR(&bucket->val, new_token);
}
/* 5. Run the update steps. */