From:             wesleygoku at yahoo dot com dot br
Operating system: Windows 2000 SP4
PHP version:      4.3.8
PHP Bug Type:     PCRE related
Bug description:  Glitch using preg_replace

Description:
------------
I'm trying to use preg_replace to evaluate my own XHTML tags, sending
their arguments and contents to another funcion. There are two uses, the
simple, without content (like <wstag x="y" />), and the complex, with
content (like <wstag x="y">x</wstag>). Each one is parsed by their own
function, and to evaluate ALL the complex tags (even the tags inside other
tags) I'm using a while condition.

The problem is very odd, it happens when I use more than one complex tag,
and some simple tag before the complex ones, all of this inside another
complex tag (you will understand better reading the code), with few
complex lines or without simple tags before them, the results are good,
but otherwise, the while condition just doesn't work and the Apache thread
takes much more time proccessing the script (I don't know why, as the while
code just repeats two times).

Look at the URL below for more details and note the first code should work
(try removing the second one), but not the second!

Reproduce code:
---------------
http://wstec.net/tmp/php_bug_pcre.html

Expected result:
----------------
<pre>NEO_HTML( &quot;list&quot;,
&quot;action=&quot;/?e=2&amp;d=lay&quot;&quot;, &quot;
        &lt;wsimg src=&quot;&quot; /&gt;
        &lt;wsimg src=&quot;&quot; /&gt;
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;Diretório
anterior&quot;&quot;, &quot;NEO_HTML( &quot;col&quot;,
&quot;width=&quot;284&quot; href=&quot;&quot;
target=&quot;_blank&quot;&quot;, &quot; &lt;img width=&quot;10&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; /&gt; &quot; )NEO_HTML(
&quot;col&quot;, &quot;width=&quot;10&quot;&quot;,
&quot;&lt;b&gt;Diretório anterior&lt;/b&gt;&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;&quot; target=&quot;_blank&quot;&quot;,
&quot;Diretório&quot; )NEO_HTML( &quot;col&quot;, &quot;href=&quot;&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;&quot;
)&quot; )
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;css.css&quot;&quot;,
&quot;NEO_HTML( &quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/css.css&quot; target=&quot;_blank&quot;&quot;, &quot; &lt;img
width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; /&gt;
&quot; )NEO_HTML( &quot;col&quot;, &quot;width=&quot;10&quot;&quot;,
&quot;css.css&quot; )NEO_HTML( &quot;col&quot;,
&quot;href=&quot;/css.css&quot; target=&quot;_blank&quot;&quot;,
&quot;Estilo CSS&quot; )NEO_HTML( &quot;col&quot;,
&quot;href=&quot;/css.css&quot; target=&quot;_blank&quot;
align=&quot;right&quot;&quot;, &quot;3,23 KB&quot; )&quot; )
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;ico.gif&quot;&quot;,
&quot;NEO_HTML( &quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/ico.gif&quot; target=&quot;_blank&quot;&quot;, &quot; &lt;img
width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; /&gt;
&quot; )NEO_HTML( &quot;col&quot;, &quot;width=&quot;10&quot;&quot;,
&quot;ico.gif&quot; )NEO_HTML( &quot;col&quot;,
&quot;href=&quot;/ico.gif&quot; target=&quot;_blank&quot;&quot;,
&quot;Imagem&quot; )NEO_HTML( &quot;col&quot;,
&quot;href=&quot;/ico.gif&quot; target=&quot;_blank&quot;
align=&quot;right&quot;&quot;, &quot;66 Bytes&quot; )&quot; )
        NEO_HTML( &quot;item&quot;,
&quot;id=&quot;list_order_asc.gif&quot;&quot;, &quot;NEO_HTML(
&quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/list_order_asc.gif&quot; target=&quot;_blank&quot;&quot;,
&quot; &lt;img width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; /&gt; &quot; )NEO_HTML( &quot;col&quot;,
&quot;width=&quot;10&quot;&quot;, &quot;list_order_asc.gif&quot;
)NEO_HTML( &quot;col&quot;, &quot;href=&quot;/list_order_asc.gif&quot;
target=&quot;_blank&quot;&quot;, &quot;Imagem&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/list_order_asc.gif&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;61
Bytes&quot; )&quot; )
        NEO_HTML( &quot;item&quot;,
&quot;id=&quot;list_order_desc.gif&quot;&quot;, &quot;NEO_HTML(
&quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/list_order_desc.gif&quot; target=&quot;_blank&quot;&quot;,
&quot; &lt;img width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; /&gt; &quot; )NEO_HTML( &quot;col&quot;,
&quot;width=&quot;10&quot;&quot;, &quot;list_order_desc.gif&quot;
)NEO_HTML( &quot;col&quot;, &quot;href=&quot;/list_order_desc.gif&quot;
target=&quot;_blank&quot;&quot;, &quot;Imagem&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/list_order_desc.gif&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;61
Bytes&quot; )&quot; )
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;top_admin.gif&quot;&quot;,
&quot;NEO_HTML( &quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/top_admin.gif&quot; target=&quot;_blank&quot;&quot;, &quot;
&lt;img width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; /&gt; &quot; )NEO_HTML( &quot;col&quot;,
&quot;width=&quot;10&quot;&quot;, &quot;top_admin.gif&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_admin.gif&quot;
target=&quot;_blank&quot;&quot;, &quot;Imagem&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_admin.gif&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;1,17
KB&quot; )&quot; )
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;top_bg.gif&quot;&quot;,
&quot;NEO_HTML( &quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/top_bg.gif&quot; target=&quot;_blank&quot;&quot;, &quot;
&lt;img width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; /&gt; &quot; )NEO_HTML( &quot;col&quot;,
&quot;width=&quot;10&quot;&quot;, &quot;top_bg.gif&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_bg.gif&quot;
target=&quot;_blank&quot;&quot;, &quot;Imagem&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_bg.gif&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;149
Bytes&quot; )&quot; )
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;top_logo.gif&quot;&quot;,
&quot;NEO_HTML( &quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/top_logo.gif&quot; target=&quot;_blank&quot;&quot;, &quot;
&lt;img width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; /&gt; &quot; )NEO_HTML( &quot;col&quot;,
&quot;width=&quot;10&quot;&quot;, &quot;top_logo.gif&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_logo.gif&quot;
target=&quot;_blank&quot;&quot;, &quot;Imagem&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_logo.gif&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;2,08
KB&quot; )&quot; )
        &lt;wsfooter search=&quot;&quot; action=&quot;move|Mover&quot;
action=&quot;copy|Copiar&quot; action=&quot;remove|Remover|3&quot; /&gt;
&quot; )</pre>

Actual result:
--------------
<pre>NEO_HTML( &quot;list&quot;,
&quot;action=&quot;/?e=2&amp;d=lay&quot;&quot;, &quot;
        &lt;wsimg src=&quot;&quot; /&gt;
        &lt;wsimg src=&quot;&quot; /&gt;
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;Diretório
anterior&quot;&quot;, &quot;NEO_HTML( &quot;col&quot;,
&quot;width=&quot;284&quot; href=&quot;&quot;
target=&quot;_blank&quot;&quot;, &quot; &lt;img width=&quot;10&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; /&gt; &quot; )NEO_HTML(
&quot;col&quot;, &quot;width=&quot;10&quot;&quot;,
&quot;&lt;b&gt;Diretório anterior&lt;/b&gt;&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;&quot; target=&quot;_blank&quot;&quot;,
&quot;Diretório&quot; )NEO_HTML( &quot;col&quot;, &quot;href=&quot;&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;&quot;
)&quot; )
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;css.css&quot;&quot;,
&quot;NEO_HTML( &quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/css.css&quot; target=&quot;_blank&quot;&quot;, &quot; &lt;img
width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; /&gt;
&quot; )NEO_HTML( &quot;col&quot;, &quot;width=&quot;10&quot;&quot;,
&quot;css.css&quot; )NEO_HTML( &quot;col&quot;,
&quot;href=&quot;/css.css&quot; target=&quot;_blank&quot;&quot;,
&quot;Estilo CSS&quot; )NEO_HTML( &quot;col&quot;,
&quot;href=&quot;/css.css&quot; target=&quot;_blank&quot;
align=&quot;right&quot;&quot;, &quot;3,23 KB&quot; )&quot; )
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;ico.gif&quot;&quot;,
&quot;NEO_HTML( &quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/ico.gif&quot; target=&quot;_blank&quot;&quot;, &quot; &lt;img
width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; /&gt;
&quot; )NEO_HTML( &quot;col&quot;, &quot;width=&quot;10&quot;&quot;,
&quot;ico.gif&quot; )NEO_HTML( &quot;col&quot;,
&quot;href=&quot;/ico.gif&quot; target=&quot;_blank&quot;&quot;,
&quot;Imagem&quot; )NEO_HTML( &quot;col&quot;,
&quot;href=&quot;/ico.gif&quot; target=&quot;_blank&quot;
align=&quot;right&quot;&quot;, &quot;66 Bytes&quot; )&quot; )
        NEO_HTML( &quot;item&quot;,
&quot;id=&quot;list_order_asc.gif&quot;&quot;, &quot;NEO_HTML(
&quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/list_order_asc.gif&quot; target=&quot;_blank&quot;&quot;,
&quot; &lt;img width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; /&gt; &quot; )NEO_HTML( &quot;col&quot;,
&quot;width=&quot;10&quot;&quot;, &quot;list_order_asc.gif&quot;
)NEO_HTML( &quot;col&quot;, &quot;href=&quot;/list_order_asc.gif&quot;
target=&quot;_blank&quot;&quot;, &quot;Imagem&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/list_order_asc.gif&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;61
Bytes&quot; )&quot; )
        NEO_HTML( &quot;item&quot;,
&quot;id=&quot;list_order_desc.gif&quot;&quot;, &quot;NEO_HTML(
&quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/list_order_desc.gif&quot; target=&quot;_blank&quot;&quot;,
&quot; &lt;img width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; /&gt; &quot; )NEO_HTML( &quot;col&quot;,
&quot;width=&quot;10&quot;&quot;, &quot;list_order_desc.gif&quot;
)NEO_HTML( &quot;col&quot;, &quot;href=&quot;/list_order_desc.gif&quot;
target=&quot;_blank&quot;&quot;, &quot;Imagem&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/list_order_desc.gif&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;61
Bytes&quot; )&quot; )
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;top_admin.gif&quot;&quot;,
&quot;NEO_HTML( &quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/top_admin.gif&quot; target=&quot;_blank&quot;&quot;, &quot;
&lt;img width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; /&gt; &quot; )NEO_HTML( &quot;col&quot;,
&quot;width=&quot;10&quot;&quot;, &quot;top_admin.gif&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_admin.gif&quot;
target=&quot;_blank&quot;&quot;, &quot;Imagem&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_admin.gif&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;1,17
KB&quot; )&quot; )
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;top_bg.gif&quot;&quot;,
&quot;NEO_HTML( &quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/top_bg.gif&quot; target=&quot;_blank&quot;&quot;, &quot;
&lt;img width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; /&gt; &quot; )NEO_HTML( &quot;col&quot;,
&quot;width=&quot;10&quot;&quot;, &quot;top_bg.gif&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_bg.gif&quot;
target=&quot;_blank&quot;&quot;, &quot;Imagem&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_bg.gif&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;149
Bytes&quot; )&quot; )
        NEO_HTML( &quot;item&quot;, &quot;id=&quot;top_logo.gif&quot;&quot;,
&quot;NEO_HTML( &quot;col&quot;, &quot;width=&quot;284&quot;
href=&quot;/top_logo.gif&quot; target=&quot;_blank&quot;&quot;, &quot;
&lt;img width=&quot;10&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot; a=&quot;1&quot;
a=&quot;1&quot; /&gt; &quot; )NEO_HTML( &quot;col&quot;,
&quot;width=&quot;10&quot;&quot;, &quot;top_logo.gif&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_logo.gif&quot;
target=&quot;_blank&quot;&quot;, &quot;Imagem&quot; )NEO_HTML(
&quot;col&quot;, &quot;href=&quot;/top_logo.gif&quot;
target=&quot;_blank&quot; align=&quot;right&quot;&quot;, &quot;2,08
KB&quot; )&quot; )
        &lt;wsfooter search=&quot;&quot; action=&quot;move|Mover&quot;
action=&quot;copy|Copiar&quot; action=&quot;remove|Remover|3&quot; /&gt;
&quot; )</pre>

-- 
Edit bug report at http://bugs.php.net/?id=29802&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=29802&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=29802&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=29802&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=29802&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=29802&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=29802&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=29802&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=29802&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=29802&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=29802&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=29802&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=29802&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=29802&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=29802&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=29802&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=29802&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=29802&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=29802&r=float

Reply via email to