Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 8.1k
Promote warnings to exceptions in ext/pcre#6006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Uh oh!
There was an error while loading. Please reload this page.
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -543,7 +543,7 @@ static zend_string **make_subpats_table(uint32_t num_subpats, pcre_cache_entry * | ||
| const char *name = name_table + 2; | ||
| subpat_names[name_idx] = zend_string_init(name, strlen(name), 0); | ||
| if (is_numeric_string(ZSTR_VAL(subpat_names[name_idx]), ZSTR_LEN(subpat_names[name_idx]), NULL, NULL, 0) > 0) { | ||
| php_error_docref(NULL, E_WARNING, "Numeric named subpatterns are not allowed"); | ||
| zend_value_error("%s(): Numeric named subpatterns are not allowed", get_active_function_name()); | ||
| free_subpats_table(subpat_names, num_subpats); | ||
| return NULL; | ||
| } | ||
| @@ -621,8 +621,12 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in | ||
| if (key != regex) { | ||
| zend_string_release_ex(key, 0); | ||
| } | ||
| php_error_docref(NULL, E_WARNING, | ||
| p < ZSTR_VAL(regex) + ZSTR_LEN(regex) ? "Null byte in regex" : "Empty regular expression"); | ||
| if (p < ZSTR_VAL(regex) + ZSTR_LEN(regex)) { | ||
| zend_type_error("%s(): Regular expression cannot contain any null-bytes", get_active_function_name()); | ||
| } else { | ||
| zend_value_error("%s(): Regular expression cannot be empty", get_active_function_name()); | ||
| } | ||
| pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); | ||
| return NULL; | ||
| } | ||
| @@ -634,7 +638,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in | ||
| if (key != regex) { | ||
| zend_string_release_ex(key, 0); | ||
| } | ||
| php_error_docref(NULL,E_WARNING, "Delimiter must not be alphanumeric or backslash"); | ||
| zend_value_error("%s(): Regular expression delimiter cannot be alphanumeric or a backslash", get_active_function_name()); | ||
| pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); | ||
| return NULL; | ||
| } | ||
| @@ -678,11 +682,11 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in | ||
| zend_string_release_ex(key, 0); | ||
| } | ||
| if (pp < ZSTR_VAL(regex) + ZSTR_LEN(regex)) { | ||
| php_error_docref(NULL,E_WARNING, "Null byte in regex"); | ||
| zend_type_error("%s(): Regular expression cannot contain any null-bytes", get_active_function_name()); | ||
| } else if (start_delimiter == end_delimiter) { | ||
| php_error_docref(NULL,E_WARNING, "No ending delimiter '%c' found", delimiter); | ||
| zend_value_error("%s(): Regular expression doesn't contain an ending delimiter \"%c\"", get_active_function_name(), delimiter); | ||
| } else { | ||
| php_error_docref(NULL,E_WARNING, "No ending matching delimiter '%c' found", delimiter); | ||
| zend_value_error("%s(): No ending matching delimiter \"%c\" found", get_active_function_name(), delimiter); | ||
| } | ||
| pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); | ||
| return NULL; | ||
| @@ -731,9 +735,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in | ||
| default: | ||
| if (pp[-1]) { | ||
| php_error_docref(NULL,E_WARNING, "Unknown modifier '%c'", pp[-1]); | ||
| zend_value_error("%s(): Regular expression modifier \"%c\" is invalid", get_active_function_name(), pp[-1]); | ||
| } else { | ||
| php_error_docref(NULL,E_WARNING, "Null byte in regex"); | ||
| zend_type_error("%s(): Regular expression cannot contain any null-bytes", get_active_function_name()); | ||
| } | ||
| pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); | ||
| efree(pattern); | ||
| @@ -745,7 +749,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in | ||
| } | ||
| if (poptions & PREG_REPLACE_EVAL) { | ||
| php_error_docref(NULL, E_WARNING, "The /e modifier is no longer supported, use preg_replace_callback instead"); | ||
| zend_value_error("%s(): Regular expression modifier \"e\" is no longer supported, use preg_replace_callback instead", get_active_function_name()); | ||
| pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); | ||
| efree(pattern); | ||
| if (key != regex) { | ||
| @@ -1193,7 +1197,7 @@ 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"); | ||
| zend_argument_value_error(4, "must be a PREG_* constant"); | ||
kocsismate marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return; | ||
| } | ||
| } else { | ||
| @@ -2404,15 +2408,13 @@ PHP_FUNCTION(preg_replace_callback_array) | ||
| ZEND_HASH_FOREACH_STR_KEY_VAL(pattern, str_idx_regex, replace) { | ||
| if (!str_idx_regex) { | ||
| php_error_docref(NULL, E_WARNING, "Delimiter must not be alphanumeric or backslash"); | ||
| zend_value_error("%s(): Regular expression delimiter cannot be alphanumeric or a backslash", get_active_function_name()); | ||
| zval_ptr_dtor(return_value); | ||
| RETURN_NULL(); | ||
| } | ||
| 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"); | ||
kocsismate marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| RETURN_THROWS(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.