From: Dmitry Stogov Date: Wed, 18 Jul 2018 13:35:17 +0000 (+0300) Subject: Move "/e" modifier check into regex compiler X-Git-Tag: php-7.3.0beta1~109 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=29f942b3d03e9b7ef4cc06e05928012a092ffdb7;p=php Move "/e" modifier check into regex compiler --- diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 22f3d15313..ffa9d79e0a 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -715,6 +715,18 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) } } + if (poptions & PREG_REPLACE_EVAL) { + php_error_docref(NULL, E_WARNING, "The /e modifier is no longer supported, use preg_replace_callback instead"); + pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); + efree(pattern); +#if HAVE_SETLOCALE + if (key != regex) { + zend_string_release_ex(key, 0); + } +#endif + return NULL; + } + #if HAVE_SETLOCALE if (key != regex) { tables = (uint8_t *)zend_hash_find_ptr(&char_tables, BG(locale_string)); @@ -1517,11 +1529,6 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su zend_string *result; /* Result of replacement */ pcre2_match_data *match_data; - if (UNEXPECTED(pce->preg_options & PREG_REPLACE_EVAL)) { - php_error_docref(NULL, E_WARNING, "The /e modifier is no longer supported, use preg_replace_callback instead"); - return NULL; - } - /* Calculate the size of the offsets array, and allocate memory for it. */ num_subpats = pce->capture_count + 1; @@ -1760,11 +1767,6 @@ static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_strin pcre2_match_data *match_data; zend_bool old_mdata_used; - if (UNEXPECTED(pce->preg_options & PREG_REPLACE_EVAL)) { - php_error_docref(NULL, E_WARNING, "The /e modifier is no longer supported, use preg_replace_callback instead"); - return NULL; - } - /* Calculate the size of the offsets array, and allocate memory for it. */ num_subpats = pce->capture_count + 1;