mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-7.4'
This commit is contained in:
commit
21e631e473
6 changed files with 49 additions and 1 deletions
|
@ -63,6 +63,7 @@ typedef void OnigMatchParam;
|
|||
#define onig_new_match_param() (NULL)
|
||||
#define onig_initialize_match_param(x) (void)(x)
|
||||
#define onig_set_match_stack_limit_size_of_match_param(x, y)
|
||||
#define onig_set_retry_limit_in_match_of_match_param(x, y)
|
||||
#define onig_free_match_param(x)
|
||||
#define onig_search_with_param(reg, str, end, start, range, region, option, mp) \
|
||||
onig_search(reg, str, end, start, range, region, option)
|
||||
|
@ -1007,6 +1008,9 @@ static int _php_mb_match_regex(void *opaque, const char *str, size_t str_len)
|
|||
if (!ZEND_LONG_UINT_OVFL(MBSTRG(regex_stack_limit))) {
|
||||
onig_set_match_stack_limit_size_of_match_param(mp, (unsigned int)MBSTRG(regex_stack_limit));
|
||||
}
|
||||
if (!ZEND_LONG_UINT_OVFL(MBSTRG(regex_retry_limit))) {
|
||||
onig_set_retry_limit_in_match_of_match_param(mp, (unsigned int)MBSTRG(regex_retry_limit));
|
||||
}
|
||||
/* search */
|
||||
err = onig_search_with_param((php_mb_regex_t *)opaque, (const OnigUChar *)str,
|
||||
(const OnigUChar*)str + str_len, (const OnigUChar *)str,
|
||||
|
@ -1471,6 +1475,7 @@ PHP_INI_BEGIN()
|
|||
strict_detection, zend_mbstring_globals, mbstring_globals)
|
||||
#if HAVE_MBREGEX
|
||||
STD_PHP_INI_ENTRY("mbstring.regex_stack_limit", "100000",PHP_INI_ALL, OnUpdateLong, regex_stack_limit, zend_mbstring_globals, mbstring_globals)
|
||||
STD_PHP_INI_ENTRY("mbstring.regex_retry_limit", "1000000",PHP_INI_ALL, OnUpdateLong, regex_retry_limit, zend_mbstring_globals, mbstring_globals)
|
||||
#endif
|
||||
PHP_INI_END()
|
||||
/* }}} */
|
||||
|
|
|
@ -167,6 +167,9 @@ ZEND_BEGIN_MODULE_GLOBALS(mbstring)
|
|||
zend_bool internal_encoding_set;
|
||||
zend_bool http_output_set;
|
||||
zend_bool http_input_set;
|
||||
#if HAVE_MBREGEX
|
||||
zend_long regex_retry_limit;
|
||||
#endif
|
||||
ZEND_END_MODULE_GLOBALS(mbstring)
|
||||
|
||||
#define MBSTRG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mbstring, v)
|
||||
|
|
|
@ -37,6 +37,7 @@ typedef void OnigMatchParam;
|
|||
#define onig_new_match_param() (NULL)
|
||||
#define onig_initialize_match_param(x) (void)(x)
|
||||
#define onig_set_match_stack_limit_size_of_match_param(x, y)
|
||||
#define onig_set_retry_limit_in_match_of_match_param(x, y)
|
||||
#define onig_free_match_param(x)
|
||||
#define onig_search_with_param(reg, str, end, start, range, region, option, mp) \
|
||||
onig_search(reg, str, end, start, range, region, option)
|
||||
|
@ -872,6 +873,9 @@ static int _php_mb_onig_search(regex_t* reg, const OnigUChar* str, const OnigUCh
|
|||
if (!ZEND_LONG_UINT_OVFL(MBSTRG(regex_stack_limit))) {
|
||||
onig_set_match_stack_limit_size_of_match_param(mp, (unsigned int)MBSTRG(regex_stack_limit));
|
||||
}
|
||||
if (!ZEND_LONG_UINT_OVFL(MBSTRG(regex_retry_limit))) {
|
||||
onig_set_retry_limit_in_match_of_match_param(mp, (unsigned int)MBSTRG(regex_retry_limit));
|
||||
}
|
||||
/* search */
|
||||
err = onig_search_with_param(reg, str, end, start, range, region, option, mp);
|
||||
onig_free_match_param(mp);
|
||||
|
@ -1363,6 +1367,9 @@ PHP_FUNCTION(mb_ereg_match)
|
|||
if (MBSTRG(regex_stack_limit) > 0 && MBSTRG(regex_stack_limit) < UINT_MAX) {
|
||||
onig_set_match_stack_limit_size_of_match_param(mp, (unsigned int)MBSTRG(regex_stack_limit));
|
||||
}
|
||||
if (MBSTRG(regex_retry_limit) > 0 && MBSTRG(regex_retry_limit) < UINT_MAX) {
|
||||
onig_set_retry_limit_in_match_of_match_param(mp, (unsigned int)MBSTRG(regex_retry_limit));
|
||||
}
|
||||
/* match */
|
||||
err = onig_match_with_param(re, (OnigUChar *)string, (OnigUChar *)(string + string_len), (OnigUChar *)string, NULL, 0, mp);
|
||||
onig_free_match_param(mp);
|
||||
|
|
23
ext/mbstring/tests/retry_limit.phpt
Normal file
23
ext/mbstring/tests/retry_limit.phpt
Normal file
|
@ -0,0 +1,23 @@
|
|||
--TEST--
|
||||
Oniguruma retry limit
|
||||
--SKIPIF--
|
||||
<?php
|
||||
extension_loaded('mbstring') or die('skip mbstring not available');
|
||||
if (!function_exists('mb_ereg')) die('skip mb_ereg not available');
|
||||
if (version_compare(MB_ONIGURUMA_VERSION, '6.8.0') < 0) {
|
||||
die('skip requires Oniguruma 6.8.0');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$regex = 'A(B|C+)+D|AC+X';
|
||||
$str = 'ACCCCCCCCCCCCCCCCCCCX';
|
||||
var_dump(mb_ereg($regex, $str));
|
||||
ini_set('mbstring.regex_retry_limit', '100000');
|
||||
var_dump(mb_ereg($regex, $str));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(1)
|
||||
bool(false)
|
|
@ -1662,6 +1662,11 @@ zend.assertions = 1
|
|||
; Default: 100000
|
||||
;mbstring.regex_stack_limit=100000
|
||||
|
||||
; This directive specifies maximum retry count for mbstring regular expressions. It is similar
|
||||
; to the pcre.backtrack_limit for PCRE.
|
||||
; Default: 1000000
|
||||
;mbstring.regex_retry_limit=1000000
|
||||
|
||||
[gd]
|
||||
; Tell the jpeg decode to ignore warnings and try to create
|
||||
; a gd image. The warning will then be displayed as notices
|
||||
|
|
|
@ -1664,6 +1664,11 @@ zend.assertions = -1
|
|||
; Default: 100000
|
||||
;mbstring.regex_stack_limit=100000
|
||||
|
||||
; This directive specifies maximum retry count for mbstring regular expressions. It is similar
|
||||
; to the pcre.backtrack_limit for PCRE.
|
||||
; Default: 1000000
|
||||
;mbstring.regex_retry_limit=1000000
|
||||
|
||||
[gd]
|
||||
; Tell the jpeg decode to ignore warnings and try to create
|
||||
; a gd image. The warning will then be displayed as notices
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue