php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44145 preg_replace using the e modifier problem
Submitted: 2008-02-18 08:56 UTC Modified: 2008-02-18 11:32 UTC
From: phong dot ek at gmail dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.5 OS: gentoo
Private report: No CVE-ID: None
 [2008-02-18 08:56 UTC] phong dot ek at gmail dot com
Description:
------------
see reproduce code. 

Reproduce code:
---------------
$message = '<a href="http://www.xxx.com" target="_blank" class="des_link" style="text-decoration:none">xxx</a>';

echo $message = preg_replace("/href=\"(.+)?\"/e", "'href=\""."out.php?date='.htmlspecialchars(date('Y-m-d H:i:s')).'&d='.urlencode('$1').'\"'", $message);

Expected result:
----------------
<a href="out.php?date=2008-02-18 15:43:03&d=http%3A%2F%2Fwww.xxx.com" target="_blank" class="des_link" style="text-decoration:none">xxx</a>

Actual result:
--------------
<a href="out.php?date=2008-02-18 15:43:03&d=http%3A%2F%2Fwww.xxx.com%5C%22+target%3D%5C%22_blank%5C%22+class%3D%5C%22des_link%5C%22+style%3D%5C%22text-decoration%3Anone">xxx</a>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-18 11:32 UTC] felipe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This isn't a bug. Your regexp is wrong.

Change (.+)? to (.+?), or ([^\"]+).

For more information:
http://www.pcre.org/man.txt


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 16:01:33 2024 UTC