php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42543 PHP 5.2.3 and 5.2.4 preg_match will fail to match strings exceeding 480 chars
Submitted: 2007-09-04 14:07 UTC Modified: 2007-09-04 14:34 UTC
From: laurent at 2mx dot fr Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.4 OS: Debian 4.0 etch
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: laurent at 2mx dot fr
New email:
PHP Version: OS:

 

 [2007-09-04 14:07 UTC] laurent at 2mx dot fr
Description:
------------
PHP 5.2.3 and 5.2.4 preg_match will fail to match strings exceeding 480 chars while it is working correctly with php 5.2.0


I'm using the bundled PCRE library
I have change the pcre.backtrack_limit but it didn't fix the problem


This is the same behavior with preg_replace_callback: the call back function doesn't get called. 


Reproduce code:
---------------
<?php

$regex = ';^<code(\s[^>]*)?>((?:(?R)|.)*?)\n</code>(\s|$);msi';

$texte = '
<code type="php">
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</code>
';


echo preg_match($regex, $texte);

?>


Expected result:
----------------
preg_match should return 1

Actual result:
--------------
preg_match
return 0 on php 5.2.4 and 5.2.3 while I'm expecting 1
return 1 on php 5.2.0 -> OK


If I remove one char "a" on the last line
preg_match
return 0 on php 5.2.4 and 5.2.3 -> OK
return 1 on php 5.2.0 -> OK


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-04 14:34 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

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