mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fixed bug #75089 (preg_grep() is not reporting PREG_BAD_UTF8_ERROR after first input string)
This commit is contained in:
parent
6c3c88074c
commit
ef90e37bd1
3 changed files with 14 additions and 7 deletions
3
NEWS
3
NEWS
|
@ -2,6 +2,9 @@ PHP NEWS
|
||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
?? ??? ????, PHP 7.2.0RC1
|
?? ??? ????, PHP 7.2.0RC1
|
||||||
|
|
||||||
|
- PCRE:
|
||||||
|
. Fixed bug #75089 (preg_grep() is not reporting PREG_BAD_UTF8_ERROR after
|
||||||
|
first input string). (Dmitry)
|
||||||
|
|
||||||
17 Aug 2017, PHP 7.2.0beta3
|
17 Aug 2017, PHP 7.2.0beta3
|
||||||
|
|
||||||
|
|
|
@ -2537,7 +2537,7 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
|
||||||
int *offsets; /* Array of subpattern offsets */
|
int *offsets; /* Array of subpattern offsets */
|
||||||
int size_offsets; /* Size of the offsets array */
|
int size_offsets; /* Size of the offsets array */
|
||||||
int count = 0; /* Count of matched subpatterns */
|
int count = 0; /* Count of matched subpatterns */
|
||||||
int no_utf_check = 0; /* Execution options */
|
int no_utf_check; /* Execution options */
|
||||||
zend_string *string_key;
|
zend_string *string_key;
|
||||||
zend_ulong num_key;
|
zend_ulong num_key;
|
||||||
zend_bool invert; /* Whether to return non-matching
|
zend_bool invert; /* Whether to return non-matching
|
||||||
|
@ -2569,18 +2569,13 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
|
||||||
|
|
||||||
PCRE_G(error_code) = PHP_PCRE_NO_ERROR;
|
PCRE_G(error_code) = PHP_PCRE_NO_ERROR;
|
||||||
|
|
||||||
#ifdef HAVE_PCRE_JIT_SUPPORT
|
|
||||||
if (!(pce->compile_options & PCRE_UTF8)) {
|
|
||||||
no_utf_check = PCRE_NO_UTF8_CHECK;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Go through the input array */
|
/* Go through the input array */
|
||||||
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(input), num_key, string_key, entry) {
|
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(input), num_key, string_key, entry) {
|
||||||
zend_string *subject_str = zval_get_string(entry);
|
zend_string *subject_str = zval_get_string(entry);
|
||||||
|
|
||||||
/* Perform the match */
|
/* Perform the match */
|
||||||
#ifdef HAVE_PCRE_JIT_SUPPORT
|
#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)
|
if ((extra->flags & PCRE_EXTRA_EXECUTABLE_JIT)
|
||||||
&& no_utf_check) {
|
&& no_utf_check) {
|
||||||
count = pcre_jit_exec(pce->re, extra, ZSTR_VAL(subject_str),
|
count = pcre_jit_exec(pce->re, extra, ZSTR_VAL(subject_str),
|
||||||
|
|
9
ext/pcre/tests/bug75089.phpt
Normal file
9
ext/pcre/tests/bug75089.phpt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #75089 (preg_grep() is not reporting PREG_BAD_UTF8_ERROR after first input string)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
preg_grep('#\d#u', ['a', "1\xFF"/*, 'c'*/]);
|
||||||
|
var_dump(preg_last_error());
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
int(4)
|
Loading…
Add table
Add a link
Reference in a new issue