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
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: spam at dragy dot de
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2022 The PHP Group
All rights reserved.
Last updated: Fri May 27 13:06:06 2022 UTC