|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39405 regular expression breaking on strings >= 24999 characters
Submitted: 2006-11-06 18:45 UTC Modified: 2006-11-14 19:07 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: spam at dragy dot de Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.0 OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: spam at dragy dot de
New email:
PHP Version: OS:


 [2006-11-06 18:45 UTC] spam at dragy dot de
The following preg_replace breaks when the string is => 24999 characters. Works perfectly fine with 24998 characters and worked fine with any strings in PHP 5.1.5.

Reproduce code:
$string = str_repeat('a', 100000);
echo preg_replace('#(^.*|.*)(\[(php|html|noparse)\].*\[/\\3])(.*|.*$)#siUe', '', $string);

Expected result:
100.000 times 'a'

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-06 20:48 UTC] ludvig dot ericson at gmail dot com
This is because of limits intentionally set, see the ini setting pcre.backtrack_limit.
 [2006-11-06 20:50 UTC] spam at dragy dot de
pcre.backtrack_limit=-1 in php.ini
 [2006-11-14 19:07 UTC]
I was wrong, there are pcre.backtrack_limit and pcre.recursion_limit directives, which might be used to control this functionality.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri May 27 13:06:06 2022 UTC