From: inf3rno dot hu at gmail dot com
Operating system: Windows XP
PHP version: 5.2.10
PHP Bug Type: PCRE related
Bug description: Bug in recursive regex processing
Description:
------------
I developed a recursive regex pattern for compile template patterns.
During the tests I found this bug. I managed to restrict it to the
following piece of code.
The count of the numbers, and every character (\n too) counts. So if I
have 11+ characters long string in the 'y'-s block, then it's buggy, but by
10- character long strings it works fine.
I hope it's a real bug, and not a damage in my computer. :-)
Reproduce code:
---------------
$pattern='%.*?(?:([a-z])(?:.*?(?:(?R).*?)*?\1)?|$)%sD';
$test='
x
0123456789
x
y
01234567890
y';
preg_match_all($pattern,$test,$matches,PREG_SET_ORDER);
var_dump($matches);
Expected result:
----------------
array(3) { [0]=> array(2) { [0]=> string(18) " x 0123456789 x" [1]=>
string(1) "x" } [1]=> array(2) { [0]=> string(19) " y 01234567890 y"
[1]=> string(1) "y" } [2]=> array(1) { [0]=> string(0) "" } }
Actual result:
--------------
array(0) { }
--
Edit bug report at http://bugs.php.net/?id=49333&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=49333&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=49333&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=49333&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=49333&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=49333&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=49333&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=49333&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=49333&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=49333&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=49333&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=49333&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=49333&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=49333&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=49333&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49333&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49333&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=49333&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=49333&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=49333&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=49333&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=49333&r=mysqlcfg