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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC