#49699 [Opn]: str_rot13 in combination with preg_replace doesnt work
| From: | william at 1moment dot nl | Date: | Mon, 28 Sep 2009 15:39:19 +0000 |
| Subject: | #49699 [Opn]: str_rot13 in combination with preg_replace doesnt work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-143002@lists.php.net to get a copy of this message | ||
ID: 49699
User updated by: william at 1moment dot nl
Reported By: william at 1moment dot nl
Status: Open
Bug Type: Unknown/Other Function
Operating System: UNIX
PHP Version: 5.3SVN-2009-09-28 (SVN)
New Comment:
Sorry the expected result should be:
<a href="/folder/?e=rknzcyr+rknzcyr+com">
and the actual result should be:
<a href="/folder/?e=example+example+com">
Previous Comments:
------------------------------------------------------------------------
[2009-09-28 15:37:03] william at 1moment dot nl
Description:
------------
When using str_rot13 within a preg_replace context the string won't be
rotated, but stays the same.
Reproduce code:
---------------
function addRotation($string) {
//return md5($string); // This works
return str_rot13($string); // This won't work
}
$output = '<html><head><head><body><a
href="mailto:example@example.com">this
is a test</a></body></html>';
$parsed =
preg_replace("/\"mailto:([A-Za-z0-9._%-]+)\@([A-Za-z0-9._%-]+)\.([A-Za-z.]{2,4})\"/",
"\"folder/?e=" . addRotation('\\1') . "+" .
addRotation('\\2') . "+"
. addRotation('\\3') ."\" rel=\"nofollow\"
target=\"_blank\"",
$output);
echo $parsed;
Expected result:
----------------
<html><head><head><body><a
href="/folder/?e=rknzcyr@rknzcyr.com">this
is a test</a></body></html>
Actual result:
--------------
<html><head><head><body><a
href="/folder/?e=example@example.com">this
is a test</a></body></html>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49699&edit=1