Promote warnings to exceptions in ext/pcre

Closes GH-6006
This commit is contained in:
Máté Kocsis 2020-08-25 18:06:07 +02:00
parent 2369f48092
commit ea87d0480f
No known key found for this signature in database
GPG key ID: FD055E41728BF310
3 changed files with 10 additions and 9 deletions

View file

@ -1193,8 +1193,8 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str,
}
if ((global && (subpats_order < PREG_PATTERN_ORDER || subpats_order > PREG_SET_ORDER)) ||
(!global && subpats_order != 0)) {
php_error_docref(NULL, E_WARNING, "Invalid flags specified");
return;
zend_argument_value_error(4, "must be a PREG_* constant");
RETURN_THROWS();
}
} else {
offset_capture = 0;
@ -2410,9 +2410,7 @@ PHP_FUNCTION(preg_replace_callback_array)
}
if (!zend_is_callable_ex(replace, NULL, 0, NULL, &fcc, NULL)) {
zend_string *callback_name = zend_get_callable_name(replace);
zend_type_error("'%s' is not a valid callback", ZSTR_VAL(callback_name));
zend_string_release_ex(callback_name, 0);
zend_argument_type_error(1, "must contain only valid callbacks");
RETURN_THROWS();
}

View file

@ -3,7 +3,11 @@ preg_* with bogus vals
--FILE--
<?php
var_dump(preg_match_all('//', '', $dummy, 0xdead));
try {
preg_match_all('//', '', $dummy, 0xdead);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
}
var_dump(preg_quote(''));
@ -13,8 +17,7 @@ var_dump(preg_replace('/(.)/e', 'for ($', 'abc'));
?>
--EXPECTF--
Warning: preg_match_all(): Invalid flags specified in %s002.php on line %d
NULL
preg_match_all(): Argument #4 ($flags) must be a PREG_* constant
string(0) ""
string(12) "a${1b${1c${1"

View file

@ -30,7 +30,7 @@ try {
echo "Done\n";
?>
--EXPECTF--
's' is not a valid callback
preg_replace_callback_array(): Argument #1 ($pattern) must contain only valid callbacks
string(0) ""
Warning: preg_replace_callback_array(): No ending delimiter '/' found in %spreg_replace_callback_array2.php on line %d