mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.2'
* PHP-8.2: Fix preg_replace_callback_array() pattern validation
This commit is contained in:
commit
32968f8de0
2 changed files with 19 additions and 0 deletions
|
@ -2406,6 +2406,10 @@ PHP_FUNCTION(preg_replace_callback_array)
|
||||||
zend_argument_type_error(1, "must contain only valid callbacks");
|
zend_argument_type_error(1, "must contain only valid callbacks");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
if (!str_idx_regex) {
|
||||||
|
zend_argument_type_error(1, "must contain only string patterns as keys");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
ZVAL_COPY_VALUE(&fci.function_name, replace);
|
ZVAL_COPY_VALUE(&fci.function_name, replace);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
--TEST--
|
||||||
|
preg_replace_callback_array() invalid pattern
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
preg_replace_callback_array(
|
||||||
|
[42 => function () {}],
|
||||||
|
'a',
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Fatal error: Uncaught TypeError: preg_replace_callback_array(): Argument #1 ($pattern) must contain only string patterns as keys in %s:%d
|
||||||
|
Stack trace:
|
||||||
|
#0 %s(%d): preg_replace_callback_array(Array, 'a')
|
||||||
|
#1 {main}
|
||||||
|
thrown in %s on line %d
|
Loading…
Add table
Add a link
Reference in a new issue