php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51963 preg_replace returns NULL, if in line more than 991 blanks
Submitted: 2010-06-01 10:58 UTC Modified: 2010-06-02 23:48 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: lexx918 at mail dot ru Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.13 OS: Windows XP SP3
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: lexx918 at mail dot ru
New email:
PHP Version: OS:

 

 [2010-06-01 10:58 UTC] lexx918 at mail dot ru
Description:
------------
One of my regular expressions leads to return of emptiness to functions preg_replace if the initial line contains more than 991 blanks. Example more low. The first line works, the second dies also I lose all contents.

Test script:
---------------
$text = 'test'.str_repeat(' ', 991).'test'; // work
$text = 'test'.str_repeat(' ', 992).'test'; // empty :(

if ($text = preg_replace('/(.*?\s+)"([^\s]+.*?)/', '$1<quot1>$2', $text)) {
    echo "GOOD\n";
} else {
    echo "BAD\n";
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-02 23:48 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2010-06-02 23:48 UTC] felipe@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

Checking the value of preg_last_error() after the fail will revelate you that there was a backtrack limit error. Which can be fixed by setting a new value for pcre.backtrack_limit directive. (the default is 100000)

http://docs.php.net/manual/en/pcre.configuration.php
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 23 17:05:45 2022 UTC