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
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: 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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC