avoid possibility of infinite loop in bbcode parsing

This commit is contained in:
Shish 2013-12-08 10:52:50 +00:00
parent caa6d59a87
commit 63aa4c6330

View file

@ -99,6 +99,8 @@ class BBCode extends FormatterExtension {
$end = strpos($text, "[/spoiler]");
if($end === false) break;
if($end < $start) break;
$beginning = substr($text, 0, $start);
$middle = str_rot13(substr($text, $start+$l1, ($end-$start-$l1)));
$ending = substr($text, $end + $l2, (strlen($text)-$end+$l2));
@ -124,6 +126,8 @@ class BBCode extends FormatterExtension {
$end = strpos($text, "[/code]", $start);
if($end === false) break;
if($end < $start) break;
$beginning = substr($text, 0, $start);
$middle = base64_encode(substr($text, $start+$l1, ($end-$start-$l1)));
$ending = substr($text, $end + $l2, (strlen($text)-$end+$l2));