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

 ID:                 53825
 Updated by:         fel...@php.net
 Reported by:        mikhail dot v dot gavrilov at gmail dot com
 Summary:            incorrect result preg_replace with large strings
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Ubuntu 10.10
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

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

Check out what preg_last_error() has returned to figure out why PCRE lib
has failed.



You need to increase the pcre.backtrack_limit value.



e.g. ini_set('pcre.backtrack_limit', PHP_INT_MAX);



- http://docs.php.net/manual/en/pcre.configuration.php

- http://docs.php.net/manual/en/function.preg-last-error.php


Previous Comments:
------------------------------------------------------------------------
[2011-01-23 21:28:19] mikhail dot v dot gavrilov at gmail dot com

Description:
------------
While converting phpBB code to html, preg_replace return empty string.



Test case:

<?php

        $str = '[b]';

        // Please try run this test case also with $i<99997 and compare
result's

        for ($i=0; $i<99998; $i++) $str .= 'q';

        $str = preg_replace("#\[b\](.+?)\[\/b\]#is", "[p]", $str);

        echo $str;

?>



I know about pcre.backtrack_limit, but i think in this case PCRE must
generate 

exception with fatal error.

Test script:
---------------
<?php

        $str = '[b]';

        // Please try run this test case also with $i<99997 and compare
result's

        for ($i=0; $i<99998; $i++) $str .= 'q';

        $str = preg_replace("#\[b\](.+?)\[\/b\]#is", "[p]", $str);

        echo $str;

?>

Expected result:
----------------
Return non empty string or generate exception with fatal error

Actual result:
--------------
Empty string


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



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

Reply via email to