Justtechjobs.com Find a programming school near you






Online Campus Both


php-documentation-list | 2003101

Re: [PHP-DOC] #25754 [Opn]: preg_replace() and preg_replace_callback() crash with long matches (KMM6129733V76115L0KM) From: abuse <email protected>
Date: 10/06/03

Hello-

Thank you for contacting the SBC Internet Services Policy department.

The use of SBC Internet accounts to attempt to gain unauthorized access
to a host, server or network is prohibited by our Acceptable Use Policy
which may be found at the following URL:

http://sbc.yahoo.com/terms/

I will investigate your complaint and take appropriate action.

On behalf of SBC Internet, I apologize for any inconvenience caused by
our customer. Please do not hesitate to write again if you have any
questions or if you wish to report other instances of abuse by SBC
Internet customers.

Thank you,
The SBCIS Policy department

Original Message Follows:
-------------------------

 ID: 25754
 User updated by: ilya at lebedev dot net
 Reported By: ilya at lebedev dot net
 Status: Open
 Bug Type: Documentation problem
 Operating System: Win32
 PHP Version: 4CVS-2003-10-04 (stable)
 New Comment:

Thank you. I know those limitations.

Is there a way to work with 9344 symbols long blocks on Windows?

Previous Comments:
------------------------------------------------------------------------

[2003-10-04 22:04:17] sniper <email protected>

>From http://www.pcre.org/pcre.txt, LIMITATIONS:

"The maximum length of a subject string is the largest
positive number that an integer variable can hold. However,
PCRE uses recursion to handle subpatterns and indefinite
repetition. This means that the available stack space may
limit the size of a subject string that can be processed by
certain patterns."

This propably should be mentioned in our manual pages too.

(On Linux, the example script worked fine with 9344 chars between the
tags, but 9345 crashed)

------------------------------------------------------------------------

[2003-10-04 19:56:54] ilya at lebedev dot net

Description:
------------
Regular expression from the J.Friedl's "Mastering regular expressions"
book that matches pair html tags:
#<tag([^>]*)>(((?!</?tag(?:[^>]*)>).)*)</tag>#si

When between <tag> and </tag> are more then 2100 bytes (symbols),
Apache crashes.

Same happens without "s" modifier, if string has no "newline" codes.

Reproduce code:
---------------
===

preg_replace("#<tag([^>]*)>(((?!</?tag(?:[^>]*)>).)*)</tag>#si","","<tag
>
2200 symbols</tag>");
===
or
===
function callback (&$m) { return "";};
preg_replace_callback
("#<tag([^>]*)>(((?!</?tag(?:[^>]*)>).)*)</tag>#si","callback","<tag>
2200 symbols </tag>");
===

Expected result:
----------------
Match blocks bigger then 2100 symbols long.

Actual result:
--------------
With more then 2100 sybmols between tags Apache crashes.

------------------------------------------------------------------------

-- 
Edit this bug report at http://bugs.php.net/?id=25754&edit=1