php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48938 Feels like .*? and /s is problematic, no output generated!
Submitted: 2009-07-16 04:50 UTC Modified: 2009-07-16 22:45 UTC
From: alexis at m2osw dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.10 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alexis at m2osw dot com
New email:
PHP Version: OS:

 

 [2009-07-16 04:50 UTC] alexis at m2osw dot com
Description:
------------
I have a pregex that starts looks like this:

/(?:<p.*?>)?\[.../s

(The last ... is to be interpreted as an ellipsis)

Removing the /s or the <p> tag before the \[ fixes the problem. Otherwise the preg_replace_callback() returns an empty string and never calls the callback. This is the case with several pages of data we have, although it is not easy for me to determine what triggers the problem.

P.S. If the callback does not exist, the function has a shortcut and the input is immediately returned as is.

Reproduce code:
---------------
1740 lines of code found as an attachment to that page:

http://linux.m2osw.com/pcre_php_s_modifier_bug

The main reason for the length is the HTML code, the failing code is just 1 line at the bottom.


Expected result:
----------------
($s == preg_replace_callback(...)) === TRUE

since the callback should not be called with that HTML.

Actual result:
--------------
preg_replace_callback() returns NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-16 07:10 UTC] scottmac@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Check out preg_last_error(), you've reached a limit we set in PCRE to prevent segfaults due to inefficient regular expressions.
 [2009-07-16 22:45 UTC] alexis at m2osw dot com
Okay, I see an error 2.

I got it to crash yesterday too. Interested? Anyway, I guess that's the same idea of a "too complex regex".

Thank you for replying.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 27 12:01:28 2024 UTC