Bug #69672 [Opn->Dup]: preg_replace() does not necessarily cater to u modifier
Edit report at https://bugs.php.net/bug.php?id=69672&edit=1
ID: 69672
Updated by: cmb@php.net
Reported by: cmb@php.net
Summary: preg_replace() does not necessarily cater to u
modifier
-Status: Open
+Status: Duplicate
Type: Bug
Package: PCRE related
Operating System: *
PHP Version: 5.6.9
Block user comment: N
Private report: N
New Comment:
Duplicate of bug #53823.
Previous Comments:
------------------------------------------------------------------------
[2015-05-20 14:22:52] cmb@php.net
Description:
------------
A user contributed note[1] mentions an "unexpected behavior" of
preg_replace() with regard to matching only an empty subpattern.
In my opinion, this is a bug, because UTF-8 encoded code points
must never be split when the u modifier is set. Matching for an
empty subpattern only might be regarded as a bug per se, but then
at least a warning should be raised or an error should be reported
by preg_last_error().
According to <http://3v4l.org/AMq5N> the current behavior
has been
introduced with PHP 5.2.9, and is not directly related to the PCRE
library.
[1] <http://php.net/manual/en/function.preg-replace.php#117314>
Test script:
---------------
<?php
var_dump(preg_replace('/()/u', '*', "a\xc3\x84b"));
?>
Expected result:
----------------
string(8) "*a*Ã*b*"
Actual result:
--------------
string(9) "*a*�*�*b*"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69672&edit=1
Thread (2 messages)