php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46920 preg_* fails with long matches
Submitted: 2008-12-21 22:26 UTC Modified: 2008-12-22 12:57 UTC
From: gdiego at gmail dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.8 OS: linux
Private report: No CVE-ID: None
 [2008-12-21 22:26 UTC] gdiego at gmail dot com
Description:
------------
If the match for a regex is very long, it fails.

Reproduce code:
---------------
$a='A';
for ($i = 0; $i < 1024; $i++) $a.='a';
$a.='A';
var_dump(preg_match('/A(.*?)A/', $a, $m));

$a='A';
for ($i = 0; $i < 131072; $i++) $a.='a';
$a.='A';
var_dump(preg_match('/A(.*?)A/', $a, $m));



Expected result:
----------------
int(1)
int(1)


Actual result:
--------------
int(1)
int(0)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-22 12:23 UTC] scottmac@php.net
Check preg_last_error(), you've reached one of the limits set which both are 10,000 by default.

http://www.php.net/manual/en/pcre.configuration.php
 [2008-12-22 12:23 UTC] scottmac@php.net
Check preg_last_error(), you've reached one of the limits set which both are 10,000 by default.

http://www.php.net/manual/en/pcre.configuration.php
 [2008-12-22 12:23 UTC] scottmac@php.net
Check preg_last_error(), you've reached one of the limits set which both are 10,000 by default.

http://www.php.net/manual/en/pcre.configuration.php
 [2008-12-22 12:57 UTC] scottmac@php.net
Check preg_last_error(), you've reached one of the limits set which both are 10,000 by default.

http://www.php.net/manual/en/pcre.configuration.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 02 05:01:30 2024 UTC