php.net |  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
Votes:1
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
 [2006-11-06 18:45 UTC] spam at dragy dot de
Description:
------------
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:
---------------
<?php
$string = str_repeat('a', 100000);
echo preg_replace('#(^.*|.*)(\[(php|html|noparse)\].*\[/\\3])(.*|.*$)#siUe', '', $string);
?>

Expected result:
----------------
100.000 times 'a'

Actual result:
--------------
nothing

Patches

Pull Requests

History

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] tony2001@php.net
I was wrong, there are pcre.backtrack_limit and pcre.recursion_limit directives, which might be used to control this functionality.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 23:01:29 2024 UTC