php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54083 Lazy match doesn't match more than 99997 characters
Submitted: 2011-02-24 01:24 UTC Modified: 2011-05-29 11:26 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: zequez at gmail dot com Assigned: iliaa (profile)
Status: Closed Package: PCRE related
PHP Version: 5.3.5 OS: Windows 7
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: zequez at gmail dot com
New email:
PHP Version: OS:

 

 [2011-02-24 01:24 UTC] zequez at gmail dot com
Description:
------------
Greedy match doesn't match more than 99997 characters. If you try to greedy match 
more than 99997 characters it matches nothing.

Test script:
---------------
// 99997 string length
$contents = '';
for ($i = 0; $i < 99997; ++$i) {
	$contents .= "a";
}

preg_match('/^a*?$/', $contents, $match);
var_dump($match);

// 99998 string length
$contents = '';
for ($i = 0; $i < 99998; ++$i) {
	$contents .= "a";
}

preg_match('/^a*?$/', $contents, $match);
var_dump($match);

Expected result:
----------------
To match the whole $contents content in both cases.

Actual result:
--------------
The first case match the whole $contents content, but in the second one it match 
nothing.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-24 01:26 UTC] zequez at gmail dot com
-Operating System: +Operating System: Windows 7
 [2011-02-24 01:26 UTC] zequez at gmail dot com
Didn't tested in other operative systems...
 [2011-02-24 04:38 UTC] zequez at gmail dot com
-Summary: Greedy match doesn't match more than 99997 characters +Summary: Lazy match doesn't match more than 99997 characters
 [2011-02-24 04:38 UTC] zequez at gmail dot com
Sorry the misspell, it's lazy, not greedy.
 [2011-02-24 13:24 UTC] aharvey@php.net
-Status: Open +Status: Verified
 [2011-02-24 13:24 UTC] aharvey@php.net
Verified on Linux.
 [2011-02-24 13:24 UTC] aharvey@php.net
-Package: Regexps related +Package: PCRE related
 [2011-02-24 13:24 UTC] aharvey@php.net
Verified on Linux.
 [2011-02-26 15:14 UTC] carsten_sttgt at gmx dot de
The default pcre.backtrack_limit of 100000 from PHP is to low for this regex.

With the PCRE default (10000000) the above regex is working.
 [2011-05-29 11:26 UTC] iliaa@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: iliaa
 [2011-05-29 11:26 UTC] iliaa@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC