com php-src: check the encoding of argument for mb_ereg, mb_ereg_replace, mb_ereg_search_init: ext/mbs tring/php_mbregex.c
| From: | Anatol Belski | Date: | Sun, 17 Jul 2016 12:19:45 +0000 |
| Subject: | com php-src: check the encoding of argument for mb_ereg, mb_ereg_replace, mb_ereg_search_init: ext/mbs tring/php_mbregex.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93054@lists.php.net to get a copy of this message | ||
Commit: eb3e7f7c10ccfcc80caa4e74e8f71c6157b4b76a
Author: Masaki Kagaya <masakielastic@gmail.com> Sun, 1 Mar 2015 21:49:10 +0900
Committer: Anatol Belski <ab@php.net> Sun, 17 Jul 2016 14:19:45 +0200
Parents: ee6ccea3eb1d74cd82131ac4beef86d4930b51d0
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=eb3e7f7c10ccfcc80caa4e74e8f71c6157b4b76a
Log:
check the encoding of argument for mb_ereg, mb_ereg_replace, mb_ereg_search_init
Changed paths:
M ext/mbstring/php_mbregex.c
Diff:
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index b427980..a012ee2 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;
}
/* }}} */