mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Make mb_ereg_replace() pattern argument a string
This commit is contained in:
parent
ba5d2e6af3
commit
06ed6b8978
4 changed files with 16 additions and 96 deletions
|
@ -94,6 +94,9 @@ PHP 8.0 UPGRADE NOTES
|
|||
|
||||
. The 'e' modifier for mb_ereg_replace() has been removed.
|
||||
mb_ereg_replace_callback() should be used instead.
|
||||
. A non-string pattern argument to mb_ereg_replace() will now be interpreted
|
||||
as a string instead of an ASCII codepoint. The previous behavior may be
|
||||
restored with an explicit call to chr().
|
||||
|
||||
- SPL:
|
||||
. SplFileObject::fgetss() has been removed.
|
||||
|
|
|
@ -967,8 +967,6 @@ PHP_FUNCTION(mb_eregi)
|
|||
/* {{{ _php_mb_regex_ereg_replace_exec */
|
||||
static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOptionType options, int is_callable)
|
||||
{
|
||||
zval *arg_pattern_zval;
|
||||
|
||||
char *arg_pattern;
|
||||
size_t arg_pattern_len;
|
||||
|
||||
|
@ -991,7 +989,6 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
|
|||
OnigUChar *pos;
|
||||
OnigUChar *string_lim;
|
||||
char *description = NULL;
|
||||
char pat_buf[6];
|
||||
|
||||
const mbfl_encoding *enc;
|
||||
|
||||
|
@ -1010,16 +1007,16 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
|
|||
size_t option_str_len = 0;
|
||||
|
||||
if (!is_callable) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zss|s",
|
||||
&arg_pattern_zval,
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|s",
|
||||
&arg_pattern, &arg_pattern_len,
|
||||
&replace, &replace_len,
|
||||
&string, &string_len,
|
||||
&option_str, &option_str_len) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
} else {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zfs|s",
|
||||
&arg_pattern_zval,
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sfs|s",
|
||||
&arg_pattern, &arg_pattern_len,
|
||||
&arg_replace_fci, &arg_replace_fci_cache,
|
||||
&string, &string_len,
|
||||
&option_str, &option_str_len) == FAILURE) {
|
||||
|
@ -1046,26 +1043,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
|
|||
php_error_docref(NULL, E_WARNING, "The 'e' option is no longer supported, use mb_ereg_replace_callback instead");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (Z_TYPE_P(arg_pattern_zval) == IS_STRING) {
|
||||
arg_pattern = Z_STRVAL_P(arg_pattern_zval);
|
||||
arg_pattern_len = Z_STRLEN_P(arg_pattern_zval);
|
||||
} else {
|
||||
php_error_docref(NULL, E_DEPRECATED,
|
||||
"Non-string patterns will be interpreted as strings in the future. "
|
||||
"Use an explicit chr() call to preserve the current behavior");
|
||||
|
||||
/* FIXME: this code is not multibyte aware! */
|
||||
convert_to_long_ex(arg_pattern_zval);
|
||||
pat_buf[0] = (char)Z_LVAL_P(arg_pattern_zval);
|
||||
pat_buf[1] = '\0';
|
||||
pat_buf[2] = '\0';
|
||||
pat_buf[3] = '\0';
|
||||
pat_buf[4] = '\0';
|
||||
pat_buf[5] = '\0';
|
||||
|
||||
arg_pattern = pat_buf;
|
||||
arg_pattern_len = 1;
|
||||
}
|
||||
/* create regex pattern buffer */
|
||||
re = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, options, MBREX(current_mbctype), syntax);
|
||||
if (re == NULL) {
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
--TEST--
|
||||
Bug #72994 (mbc_to_code() out of bounds read)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('mbstring')) die('skip mbstring extension not available');
|
||||
if (!function_exists('mb_ereg_replace')) die('skip mb_ereg_replace() not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$var1 = mb_ereg_replace($var-232338951,NULL,NULL,NULL);
|
||||
var_dump($var1);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
Notice: Undefined variable: var in %s on line %d
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
|
||||
Warning: mb_ereg_replace(): mbregex compile err: invalid code point value in %sbug72994.php on line %d
|
||||
bool(false)
|
||||
===DONE===
|
|
@ -96,87 +96,53 @@ foreach($inputs as $input) {
|
|||
|
||||
echo "Done";
|
||||
?>
|
||||
--EXPECTF--
|
||||
--EXPECT--
|
||||
*** Testing mb_ereg_replace() : usage variations ***
|
||||
|
||||
-- Iteration 1 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 2 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 3 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 4 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
|
||||
Warning: mb_ereg_replace(): mbregex compile err: invalid code point value in %s on line %d
|
||||
bool(false)
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 5 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 6 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
|
||||
Warning: mb_ereg_replace(): mbregex compile err: invalid code point value in %s on line %d
|
||||
bool(false)
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 7 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 8 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 9 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 10 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
|
||||
|
||||
-- Iteration 11 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
|
||||
|
||||
-- Iteration 12 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 13 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
|
||||
|
||||
-- Iteration 14 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 15 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
|
||||
|
||||
-- Iteration 16 --
|
||||
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
|
||||
|
@ -194,17 +160,11 @@ string(10) "string_val"
|
|||
string(10) "string_val"
|
||||
|
||||
-- Iteration 21 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
|
||||
-- Iteration 22 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
|
||||
|
||||
-- Iteration 23 --
|
||||
|
||||
Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
|
||||
string(10) "string_val"
|
||||
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
|
||||
Done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue