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

 ID:                 52914
 Updated by:         [email protected]
 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

Reply via email to