Skip to content

Commit fcd52e5

Browse files
committed
Reviews
1 parent 9bca1f8 commit fcd52e5

File tree

6 files changed

+16
-44
lines changed

6 files changed

+16
-44
lines changed

ext/mbstring/php_mbregex.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "php_mbregex.h"
2727
#include "mbstring.h"
2828
#include "libmbfl/filters/mbfilter_utf8.h"
29-
#include <stdbool.h>
3029

3130
#include "php_onig_compat.h" /* must come prior to the oniguruma header */
3231
#include <oniguruma.h>
@@ -656,7 +655,7 @@ static bool _php_mb_regex_init_options(const char *parg, size_t narg, OnigOption
656655
return false;
657656
default:
658657
zend_value_error("Option \"%c\" is not supported", c);
659-
break;
658+
return false;
660659
}
661660
}
662661
if (option != NULL) *option|=optm;
@@ -920,8 +919,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
920919
string_len,
921920
php_mb_regex_get_mbctype_encoding()
922921
)) {
923-
zend_argument_value_error(2, "must be a valid string in \"%s\" encoding", php_mb_regex_get_mbctype());
924-
RETURN_THROWS();
922+
RETURN_FALSE;
925923
}
926924

927925
options = MBREX(regex_default_options);
@@ -1046,7 +1044,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
10461044

10471045
if (option_str != NULL) {
10481046
/* Initialize option and in case of failure it means there is a value error */
1049-
if(!_php_mb_regex_init_options(option_str, option_str_len, &options, &syntax, 4)) {
1047+
if (!_php_mb_regex_init_options(option_str, option_str_len, &options, &syntax, 4)) {
10501048
RETURN_THROWS();
10511049
}
10521050
} else {
@@ -1153,7 +1151,6 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
11531151
}
11541152
smart_str_free(&eval_buf);
11551153

1156-
// Need to investigate if failure in Oniguruma and if should throw.
11571154
if (err <= -2) {
11581155
smart_str_free(&out_buf);
11591156
RETVAL_FALSE;
@@ -1210,8 +1207,7 @@ PHP_FUNCTION(mb_split)
12101207
}
12111208

12121209
if (!php_mb_check_encoding(string, string_len, php_mb_regex_get_mbctype_encoding())) {
1213-
zend_argument_value_error(2, "must be a valid string in '%s'", php_mb_regex_get_mbctype());
1214-
RETURN_THROWS();
1210+
RETURN_FALSE;
12151211
}
12161212

12171213
/* create regex pattern buffer */
@@ -1519,13 +1515,9 @@ PHP_FUNCTION(mb_ereg_search_init)
15191515
RETVAL_TRUE;
15201516
} else {
15211517
MBREX(search_pos) = ZSTR_LEN(arg_str);
1522-
zend_argument_value_error(1, "must be a valid string in '%s'", php_mb_regex_get_mbctype());
1523-
RETURN_THROWS();
1518+
RETURN_FALSE;
15241519
}
15251520

1526-
MBREX(search_pos) = 0;
1527-
RETVAL_TRUE;
1528-
15291521
if (MBREX(search_regs) != NULL) {
15301522
onig_region_free(MBREX(search_regs), 1);
15311523
MBREX(search_regs) = NULL;

ext/mbstring/tests/bug69151.phpt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,17 @@ if (!function_exists('mb_ereg')) die('skip mbregex support not available');
99
<?php
1010
$str = "\x80";
1111

12-
try {
13-
var_dump(false === mb_eregi('.', $str, $matches));
14-
} catch (\ValueError $e) {
15-
echo $e->getMessage() . \PHP_EOL;
16-
}
12+
var_dump(false === mb_eregi('.', $str, $matches));
1713
var_dump([] === $matches);
1814

1915
var_dump(NULL === mb_ereg_replace('.', "\\0", $str));
2016

21-
try {
22-
var_dump(false === mb_ereg_search_init("\x80", '.'));
23-
} catch (\ValueError $e) {
24-
echo $e->getMessage() . \PHP_EOL;
25-
}
17+
var_dump(false === mb_ereg_search_init("\x80", '.'));
2618
var_dump(false === mb_ereg_search());
2719
?>
2820
--EXPECT--
29-
mb_eregi(): Argument #2 ($string) must be a valid string in "UTF-8" encoding
3021
bool(true)
3122
bool(true)
32-
mb_ereg_search_init(): Argument #1 ($string) must be a valid string in 'UTF-8'
23+
bool(true)
24+
bool(true)
3325
bool(true)

ext/mbstring/tests/bug73532.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ if (!function_exists('mb_ereg')) die('skip mbregex support not available');
77
?>
88
--FILE--
99
<?php
10-
try {
11-
var_dump(mb_eregi("a", "\xf5"));
12-
} catch (\ValueError $e) {
13-
echo $e->getMessage() . \PHP_EOL;
14-
}
10+
var_dump(mb_eregi("a", "\xf5"));
1511
?>
1612
--EXPECT--
17-
mb_eregi(): Argument #2 ($string) must be a valid string in "UTF-8" encoding
13+
bool(false)

ext/mbstring/tests/bug76999.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ string(2) "pr"
2323
string(2) "mr"
2424
string(3) "imd"
2525
Option "a" is not supported
26-
string(1) "r"
26+
string(2) "mr"

ext/mbstring/tests/bug77367.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ if (!function_exists('mb_split')) die('skip mb_split() not available');
88
--FILE--
99
<?php
1010
mb_regex_encoding('UTF-8');
11-
try {
12-
var_dump(mb_split("\\w", "\xfc"));
13-
} catch (\ValueError $e) {
14-
echo $e->getMessage() . \PHP_EOL;
15-
}
11+
var_dump(mb_split("\\w", "\xfc"));
1612
?>
1713
--EXPECT--
18-
mb_split(): Argument #2 ($string) must be a valid string in 'UTF-8'
14+
bool(false)

ext/mbstring/tests/bug77418.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ if (!function_exists('mb_split')) die('skip mb_split() not available');
99
<?php
1010
mb_regex_encoding("UTF-32");
1111

12-
try {
13-
var_dump(mb_split("\x00\x00\x00\x5c\x00\x00\x00B","000000000000000000000000000000"));
14-
} catch (\ValueError $e) {
15-
echo $e->getMessage() . \PHP_EOL;
16-
}
12+
var_dump(mb_split("\x00\x00\x00\x5c\x00\x00\x00B","000000000000000000000000000000"));
1713
?>
1814
--EXPECT--
19-
mb_split(): Argument #2 ($string) must be a valid string in 'UCS-4'
15+
bool(false)

0 commit comments

Comments
 (0)