#44145 [Opn->Bgs]: preg_replace using the e modifier problem
ID: 44145
Updated by: felipe@php.net
Reported By: phong dot ek at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: PCRE related
Operating System: gentoo
PHP Version: 5.2.5
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2008-02-18 08:56:34] 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>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44145&edit=1
Thread (2 messages)