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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
28 - 14 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 20:01:28 2024 UTC