#48047 [Opn->Bgs]: preg_replace returns NULL over string size
| From: | scottmac@php.net | Date: | Wed, 22 Apr 2009 13:58:10 +0000 |
| Subject: | #48047 [Opn->Bgs]: preg_replace returns NULL over string size | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-136133@lists.php.net to get a copy of this message | ||
ID: 48047
Updated by: scottmac@php.net
Reported By: goriol at technema dot fr
-Status: Open
+Status: Bogus
Bug Type: *Regular Expressions
Operating System: Windows XP
PHP Version: 5.2.9
New Comment:
preg_last_error() returns 2 which is PREG_BACKTRACK_LIMIT_ERROR.
Previous Comments:
------------------------------------------------------------------------
[2009-04-22 13:53:16] goriol at technema dot fr
Description:
------------
I found a situation where preg_replace returns NULL instead of the
expected string. The regexp I use is (perhaps) erroneous:
"/^\s*(.*?)\s*$/s"
But when the string size is less than 49997 characters, the function
returns the string properly. Over that size, the function returns NULL.
Reproduce code:
---------------
$a = str_repeat('a', 49998);
$a = preg_replace('/^\s*(.*?)\s*$/s', '$1', $a);
Expected result:
----------------
$a
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48047&edit=1