|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10111 e modifier alters string extraction in preg_replace
Submitted: 2001-04-02 08:08 UTC Modified: 2003-01-20 17:24 UTC
From: gcousin at startem dot net Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 4.0.4pl1 OS: Linux Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: gcousin at startem dot net
New email:
PHP Version: OS:


 [2001-04-02 08:08 UTC] gcousin at startem dot net
A short example :

$newsitem = preg_replace('/(<([a-zA-Z-]+) ([^>]*)analyze="[0-9]*"([^>]*)>)(.*?)(<\/\\2>)/mse', "'\\1'.transformNewsitemPart('\\5').'\\6'", $newsitem);

where I transform the text between any html tag with "analyze" attribute.

The problem is that the preg_replace function with e modifier adds backslashes before any " in the matched text (\\5) BEFORE the function transformNewsitemPart is interpreted.

The behaviour is new in php 4.0.4. It was not present in php 4.0.3.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-11 09:52 UTC] kerry at lothrop dot de
This is a nice feature, not a bug. See my user contributed note in the manual under preg_replace. Maybe someone should document this behavior.
 [2002-04-09 17:01 UTC]
this is a duplicate of #12668 (which has more discussion about the issue, which is why i'm pointing this at the later report instead of vice versa).
 [2003-01-20 17:24 UTC]
As is the one this was duplicate of: #12668

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Oct 04 10:01:25 2023 UTC