ID:               22023
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Verified
 Bug Type:         PCRE related
 Operating System: Mandrake 9.0 Linux
-PHP Version:      4.2.3
+PHP Version:      4.3.1-dev, 5.0.0-dev
 New Comment:

<?php

$foo = "test AAthis is a test of some text inside end.";

var_dump(preg_match("/AA(([^A]*A?[^A]+)+)AA/", $foo)); 

?>

This just hangs.



Previous Comments:
------------------------------------------------------------------------

[2003-02-02 17:38:56] [EMAIL PROTECTED]

This is most likely a bug in the PCRE library. It happens with certain
patterns in a no-match situation. Consider the following pattern:

/AA(([^A]*A?[^A]+)+)AA/

The letter A doesn't matter. This allows the matching of 'AA' delimited
strings, while still allowing single A's inside such strings. Note that
/AA(.*)AA/ will not work, since it will just match the outermost
enclosing of such a string. Now when matching for instance:

test AAthis is a test of some text insideAA end.

This works fine, and returns right away with preg_match or preg_replace
alike. Also with ereg it works fine (without the / pattern delimiters
of course). Now consider the similar string:

test AAthis is a test of some text inside end.

The delimiter at the end was removed. Now both preg_match and
preg_replace time out after the maximum execution time of 30 seconds.
ereg still works fine. The longer the text after the opening AA, the
longer time it takes. This is long enough to never finish (within the
allotted time), while shorter texts will make it finish after e.g. 20
seconds or so.


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


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

Reply via email to