diff options
author | Masaki Kagaya <masakielastic@gmail.com> | 2015-03-01 21:49:10 +0900 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2016-07-17 14:19:45 +0200 |
commit | eb3e7f7c10ccfcc80caa4e74e8f71c6157b4b76a (patch) | |
tree | e8d6390d733b039691dcee08bf8bc37a9d1b89b7 /ext/mbstring/php_mbregex.c | |
parent | ee6ccea3eb1d74cd82131ac4beef86d4930b51d0 (diff) | |
download | php-git-eb3e7f7c10ccfcc80caa4e74e8f71c6157b4b76a.tar.gz |
check the encoding of argument for mb_ereg, mb_ereg_replace, mb_ereg_search_init
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
-rw-r--r-- | ext/mbstring/php_mbregex.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index b427980430..a012ee2f35 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -703,6 +703,16 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) RETURN_FALSE; } + if (!php_mb_check_encoding( + string, + string_len, + _php_mb_regex_mbctype2name(MBREX(current_mbctype)) + )) { + zval_dtor(array); + array_init(array); + RETURN_FALSE; + } + options = MBREX(regex_default_options); if (icase) { options |= ONIG_OPTION_IGNORECASE; @@ -848,6 +858,14 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp } } + if (!php_mb_check_encoding( + string, + string_len, + _php_mb_regex_mbctype2name(MBREX(current_mbctype)) + )) { + RETURN_NULL(); + } + if (option_str != NULL) { _php_mb_regex_init_options(option_str, option_str_len, &options, &syntax, &eval); } else { @@ -1361,14 +1379,22 @@ PHP_FUNCTION(mb_ereg_search_init) ZVAL_DUP(&MBREX(search_str), arg_str); - MBREX(search_pos) = 0; + if (php_mb_check_encoding( + Z_STRVAL_P(arg_str), + Z_STRLEN_P(arg_str), + _php_mb_regex_mbctype2name(MBREX(current_mbctype)) + )) { + MBREX(search_pos) = 0; + RETVAL_TRUE; + } else { + MBREX(search_pos) = Z_STRLEN_P(arg_str); + RETVAL_FALSE; + } if (MBREX(search_regs) != NULL) { onig_region_free(MBREX(search_regs), 1); MBREX(search_regs) = NULL; } - - RETURN_TRUE; } /* }}} */ |