php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41788 preg_replace_callback returns NULL instead of input or error
Submitted: 2007-06-24 11:44 UTC Modified: 2007-06-24 14:24 UTC
From: Sjon at hortensius dot net Assigned:
Status: Not a bug Package: Regexps related
PHP Version: 5.2.3 OS: linux 2.6.21.5
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: Sjon at hortensius dot net
New email:
PHP Version: OS:

 

 [2007-06-24 11:44 UTC] Sjon at hortensius dot net
Description:
------------
The preg_replace_callback manual-entry says:

 If matches are found, the new subject will be returned, otherwise subject will be returned unchanged.

However; I have a testcase where no input is returned; and my callback isn't called either. This seems to be caused by a required pcre.backtrack_limit of 10000000

Shouldn't PHP return the input or an error giving some pointers about this limit being reached?

Reproduce code:
---------------
<?PHP
$input = '{?value==input.value}';
$regexp = '~\{\?(?:\(?!?.+(==)?.+\)?)+\}{\1\/}~sU';

var_dump(preg_replace_callback($regexp, 'callback', $input));

function callback(){
        die('called');
}


Expected result:
----------------
I expect an error to be raised when pcre.backtrack_limit is reached

Actual result:
--------------
NULL is var_dumped

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-24 14:24 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

See preg_last_error().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 01:01:31 2024 UTC