Bug #69672 [Opn->Dup]: preg_replace() does not necessarily cater to u modifier

From: Date: Fri, 05 Jun 2015 15:04:01 +0000
Subject: Bug #69672 [Opn->Dup]: preg_replace() does not necessarily cater to u modifier
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193148@lists.php.net to get a copy of this message
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)

« previous php.bugs (#193148) next »