|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52914 preg_replace() e-modificator bug
Submitted: 2010-09-23 16:49 UTC Modified: 2010-09-24 05:30 UTC
From: celebgolfer at gmail dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.3.3 OS: Windows 7 & FreeBSD 7.2
Private report: No CVE-ID: None
 [2010-09-23 16:49 UTC] celebgolfer at gmail dot com
preg_replace() add slashes to double quotes arbitarily.

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

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-24 05:30 UTC]
-Status: Open +Status: Bogus -Package: Scripting Engine problem +Package: PCRE related
 [2010-09-24 05:30 UTC]
This is documented behaviour. Quoting the manual at :


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.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 16 15:05:45 2022 UTC