com php-src: Fix UTF check in pcre_grep: ext/pcre/php_p cre.c
| From: | Anatol Belski | Date: | Tue, 14 Nov 2017 12:49:06 +0000 |
| Subject: | com php-src: Fix UTF check in pcre_grep: ext/pcre/php_p cre.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100226@lists.php.net to get a copy of this message | ||
Commit: 0d1332391573c1dc8218094c150cd9efcc7f6aff
Author: Anatol Belski <ab@php.net> Tue, 14 Nov 2017 13:49:06 +0100
Parents: 3c241ea3262250262c63b92176e2eec2435cc6bb
Branches: PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0d1332391573c1dc8218094c150cd9efcc7f6aff
Log:
Fix UTF check in pcre_grep
In this case it loops through different subjects without looking for sub
matches and matches are done against the same pattern. Thus, don't reset
the UTF check flag but use it to check whether JIT should be used and
otherwise let PCRE to do the job according to what was saved into the
pattern.
Changed paths:
M ext/pcre/php_pcre.c
Diff:
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index c71335f..54fd90f 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -2569,13 +2569,16 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval
*return
PCRE_G(error_code) = PHP_PCRE_NO_ERROR;
+#ifdef HAVE_PCRE_JIT_SUPPORT
+ no_utf_check = (pce->compile_options & PCRE_UTF8) ? 0 : PCRE_NO_UTF8_CHECK;
+#endif
+
/* Go through the input array */
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(input), num_key, string_key, entry) {
zend_string *subject_str = zval_get_string(entry);
/* Perform the match */
#ifdef HAVE_PCRE_JIT_SUPPORT
- no_utf_check = (pce->compile_options & PCRE_UTF8) ? 0 : PCRE_NO_UTF8_CHECK;
if ((extra->flags & PCRE_EXTRA_EXECUTABLE_JIT)
&& no_utf_check) {
count = pcre_jit_exec(pce->re, extra, ZSTR_VAL(subject_str),
@@ -2587,9 +2590,6 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval
*return
(int)ZSTR_LEN(subject_str), 0,
no_utf_check, offsets, size_offsets);
- /* the string was already proved to be valid UTF-8 */
- no_utf_check = PCRE_NO_UTF8_CHECK;
-
/* Check for too many substrings condition. */
if (count == 0) {
php_error_docref(NULL, E_NOTICE, "Matched, but too many substrings");