|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-01-23 21:28 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 21:00:01 2025 UTC |
Probably a rhetorical question and no response will not. Why not make an exception for this case? Who does not know would see right away the error, the others would put try {} catch {}.