File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-17201 (Dom\TokenList issues with interned string replace)
3
+ --EXTENSIONS--
4
+ dom
5
+ --INI--
6
+ opcache.protect_memory=1
7
+ --FILE--
8
+ <?php
9
+ $ dom = DOM \XMLDocument::createFromString ('<root class="AA B C"/> ' );
10
+ $ element = $ dom ->documentElement ;
11
+ $ list = $ element ->classList ;
12
+ $ list ->replace ('AA ' , 'AB ' ); // Use interned string
13
+ foreach ($ list as $ entry ) {
14
+ var_dump ($ entry );
15
+ }
16
+ ?>
17
+ --EXPECT--
18
+ string(2) "AB"
19
+ string(1) "B"
20
+ string(1) "C"
Original file line number Diff line number Diff line change @@ -583,7 +583,8 @@ PHP_METHOD(Dom_TokenList, replace)
583
583
/* It already exists, remove token instead. */
584
584
zend_hash_del_bucket (token_set , bucket );
585
585
} else {
586
- Z_STR (bucket -> val ) = new_token ;
586
+ /* Need to use ZVAL_STR instead of Z_STR to reset the type flags. */
587
+ ZVAL_STR (& bucket -> val , new_token );
587
588
}
588
589
589
590
/* 5. Run the update steps. */
You can’t perform that action at this time.
0 commit comments