summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/mbstring/php_mbregex.c10
-rw-r--r--ext/mbstring/tests/mb_ereg_search_syntax.phpt11
2 files changed, 16 insertions, 5 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index bc36596988..c614b0d5a4 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -1357,7 +1357,7 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode)
size_t n, i, pos, len;
/* Stored as int* in the OnigRegion struct */
int beg, end;
- OnigOptionType option;
+ OnigOptionType option = 0;
OnigUChar *str;
OnigSyntaxType *syntax;
@@ -1365,11 +1365,11 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode)
RETURN_THROWS();
}
- option = MBREX(regex_default_options);
-
if (arg_options) {
- option = 0;
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, NULL);
+ } else {
+ option |= MBREX(regex_default_options);
+ syntax = MBREX(regex_default_syntax);
}
if (MBREX(search_regs)) {
@@ -1379,7 +1379,7 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode)
if (arg_pattern) {
/* create regex pattern buffer */
- if ((MBREX(search_re) = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, option, MBREX(regex_default_syntax))) == NULL) {
+ if ((MBREX(search_re) = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, option, syntax)) == NULL) {
RETURN_FALSE;
}
}
diff --git a/ext/mbstring/tests/mb_ereg_search_syntax.phpt b/ext/mbstring/tests/mb_ereg_search_syntax.phpt
new file mode 100644
index 0000000000..977ceba8e1
--- /dev/null
+++ b/ext/mbstring/tests/mb_ereg_search_syntax.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Specifying non-default syntax in mb_ereg_search()
+--FILE--
+<?php
+
+mb_ereg_search_init("a");
+var_dump(mb_ereg_search("a\\{1,2\\}", "b"));
+
+?>
+--EXPECT--
+bool(true)