php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75089 preg_grep() is not reporting PREG_BAD_UTF8_ERROR after first input string
Submitted: 2017-08-18 07:56 UTC Modified: 2017-08-18 08:37 UTC
From: david at grudl dot com Assigned: dmitry (profile)
Status: Closed Package: PCRE related
PHP Version: 7.2.0beta3 OS:
Private report: No CVE-ID: None
 [2017-08-18 07:56 UTC] david at grudl dot com
Description:
------------
preg_grep() is not reporting PREG_BAD_UTF8_ERROR

test script: https://3v4l.org/3aY3r

Test script:
---------------
<?php

preg_grep('#\d#u', ['a', "1\xFF", 'c']); // array contains invalid utf-8 string

var_dump(preg_last_error()); // returns PREG_BAD_UTF8_ERROR in PHP < 7.2 and 0 in PREG_NO_ERROR in PHP 7.2


Expected result:
----------------
PREG_BAD_UTF8_ERROR 

Actual result:
--------------
PREG_NO_ERROR 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-18 08:37 UTC] requinix@php.net
-Summary: preg_grep() is not reporting PREG_BAD_UTF8_ERROR +Summary: preg_grep() is not reporting PREG_BAD_UTF8_ERROR after first input string -Status: Open +Status: Verified -Assigned To: +Assigned To: dmitry
 [2017-08-18 08:37 UTC] requinix@php.net
Note that it does work when the string is the first in the list.

https://github.com/php/php-src/commit/8dc6b41011c59d7df2b9227e4dbd67f242372ba8
https://github.com/php/php-src/blob/php-7.2.0beta3/ext/pcre/php_pcre.c#L2595

+		/* the string was already proved to be valid UTF-8 */
+		no_utf_check = PCRE_NO_UTF8_CHECK;

That should not be in there.
 [2017-08-18 11:58 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ef90e37bd15db5ecea57e03ad72a53acd844b706
Log: Fixed bug #75089 (preg_grep() is not reporting PREG_BAD_UTF8_ERROR after first input string)
 [2017-08-18 11:58 UTC] dmitry@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC