Bug #61971 [Opn->Nab]: apply a function to an auto-referencia(preg_replace does) not produce an effect

From: Date: Mon, 07 May 2012 22:05:26 +0000
Subject: Bug #61971 [Opn->Nab]: apply a function to an auto-referencia(preg_replace does) not produce an effect
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-170296@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61971&edit=1

 ID:                 61971
 Updated by:         nikic@php.net
 Reported by:        yoyahack at undersecurity dot net
 Summary:            apply a function to an auto-referencia(preg_replace
                     does) not produce an effect
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Output Control
 Operating System:   Linux Debian
 PHP Version:        5.4Git-2012-05-07 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The htmlentities() is executed before passing the result to preg_replace(). So in the end you just
pass '$1' on.

What you probably want to use is http://de3.php.net/manual/en/function.preg-replace-callback.php.


Previous Comments:
------------------------------------------------------------------------
[2012-05-07 21:07:41] yoyahack at undersecurity dot net

Description:
------------
when  applies a function to a auto-reference (preg_replace),  it not affect to the auto-referente

Test script:
---------------
<?php

echo preg_replace('/<!\[CDATA\[([\w\W]+?)\]\]>/i', htmlentities('$1'),
'<category><![CDATA[Examp<b>l<a>e]]></category>');

?>

Expected result:
----------------
<category>Examp&lt;b&gt;l&lt;a&gt;e</category>

Actual result:
--------------
<category>Examp<b>l<a>e</category>


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61971&edit=1


Thread (2 messages)

« previous php.bugs (#170296) next »