Bug #52914 [Opn->Bgs]: preg_replace() e-modificator bug

From: Date: Fri, 24 Sep 2010 03:30:10 +0000
Subject: Bug #52914 [Opn->Bgs]: preg_replace() e-modificator bug
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-154606@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52914&edit=1

 ID:                 52914
 Updated by:         aharvey@php.net
 Reported by:        celebgolfer at gmail dot com
 Summary:            preg_replace() e-modificator bug
-Status:             Open
+Status:             Bogus
 Type:               Bug
-Package:            Scripting Engine problem
+Package:            PCRE related
 Operating System:   Windows 7 & FreeBSD 7.2
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

This is documented behaviour. Quoting the manual at
http://au2.php.net/manual/en/reference.pcre.pattern.modifiers.php
:


e (PREG_REPLACE_EVAL)

If this modifier is set, preg_replace() does normal substitution of
backreferences in the replacement string, evaluates it as PHP code, and
uses the result for replacing the search string. Single quotes, double
quotes, backslashes (\) and NULL chars will be escaped by backslashes in
substituted backreferences.


Note the section about quotes being escaped by backslashes.


Previous Comments:
------------------------------------------------------------------------
[2010-09-23 16:49:15] celebgolfer at gmail dot com

Description:
------------
preg_replace() add slashes to double quotes arbitarily.

Test script:
---------------
echo
preg_replace("/(\".*\")/e","'[\\1]'",'"1\"\n2"');

Expected result:
----------------
["1\"\n2"]

Actual result:
--------------
[\"1\\"\n2\"]


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



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


Thread (2 messages)

« previous php.bugs (#154606) next »