Bug #76127 [Ver->Csd]: preg_split does not raise an error on invalid UTF-8

From: Date: Tue, 19 Mar 2019 12:59:57 +0000
Subject: Bug #76127 [Ver->Csd]: preg_split does not raise an error on invalid UTF-8
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220071@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76127&edit=1

 ID:                 76127
 Updated by:         nikic@php.net
 Reported by:        graefrath at femu dot rwth-aachen dot de
 Summary:            preg_split does not raise an error on invalid UTF-8
-Status:             Verified
+Status:             Closed
 Type:               Bug
 Package:            PCRE related
 PHP Version:        5.6.34
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=661bce47aebdc67bda1616e1b6979803765173a6
Log: Fixed bug #76127


Previous Comments:
------------------------------------------------------------------------
[2018-03-21 15:32:04] cmb@php.net

Confirmed: <https://3v4l.org/1WYQE>.

The problem is that although the error is detected[1],
php_pcre_split_impl() happily proceeds, while
php_pcre_match_impl() checks for an error in the end, and returns
FALSE in that case[2].

[1] <https://github.com/php/php-src/blob/PHP-7.2.4/ext/pcre/php_pcre.c#L2369>
[2] <https://github.com/php/php-src/blob/PHP-7.2.4/ext/pcre/php_pcre.c#L1134-L1139>

------------------------------------------------------------------------
[2018-03-21 13:36:09] graefrath at femu dot rwth-aachen dot de

Description:
------------
preg_match and preg_replace return false and set the last error to PREG_BAD_UTF8_ERROR when the u
modifier is specified and the subject is invalid UTF-8. However, preg_split does not behave
consistently in this regard.

Test script:
---------------
var_dump(preg_split("/a/u", "a\xff"));

Expected result:
----------------
preg_split should return false and set the last error PREG_BAD_UTF8_ERROR just like the other preg_
functions.

Actual result:
--------------
preg_split returns an array with the subject string.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=76127&edit=1


Thread (3 messages)

« previous php.bugs (#220071) next »