#34720 [Bgs]: Problem when a parenthesised sub exp matches >= 4999996 chars

From: Date: Mon, 03 Oct 2005 21:46:11 +0000
Subject: #34720 [Bgs]: Problem when a parenthesised sub exp matches >= 4999996 chars
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-85958@lists.php.net to get a copy of this message
ID: 34720 User updated by: nuitari at nuitari dot net Reported By: nuitari at nuitari dot net Status: Bogus Bug Type: PCRE related Operating System: Linux PHP Version: 5.0.5 New Comment: Would it be possible to document this in the pcre functions manual ? Previous Comments: ------------------------------------------------------------------------ [2005-10-03 22:10:21] tony2001@php.net This is a PCRE limitation, See bug #34695 for detailed explanation. ------------------------------------------------------------------------ [2005-10-03 21:39:09] nuitari at nuitari dot net Description: ------------ If a paranthesised sub expression matches more then ~4999996 chars, no data will be inserted into the &matches array. Reducing by 1 the number in str_repeat will cause the script to work. I have tested this with PHP 4.4.0-gentoo-amd64, 5.0.4-FC4, and 5.0.5-gentoo and all exhebit the same problems. The configure line is different on all platforms. php.ini is the default. On the FC4 test there is a 512Mb memory limit. Reproduce code: --------------- <?php $xml_clean = '<data>'; $xml_clean .= str_repeat('a',4999996); $xml_clean .= '</data>'; $ret = preg_match("/(<([\w]+)[^>]*>)(.*?)(<\/\\2>)/s", $xml_clean, $match); print_r($match); ?> Expected result: ---------------- Array ( [0] => <data>aaa(...)aaa</data> [1] => <data> [2] => data [3] => aaa(...)aaa [4] => </data> ) Actual result: -------------- Array ( ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34720&edit=1

« previous php.bugs (#85958) next »