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

Pull Requests

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: Sat Dec 21 16:01:28 2024 UTC