From 3c05af6553ae1bef3a59c5f58aa7551021e34363 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 6 Apr 2015 21:26:40 -0700 Subject: make open tag work correctly for multiple invocations in the same text --- include/bbcode.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index e97a96f87..5ee3d5d5e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -291,6 +291,12 @@ function bb_map_location($match) { return str_replace($match[0],'
' . generate_named_map($match[1]) . '
', $match[0]); } +function bbopentag($match) { + $rnd = mt_rand(); + return "
" . $match[1] . "
" . $match[2] . "
"; +} + + function bb_sanitize_style($input) { //whitelist property limits (0 = no limitation) @@ -672,9 +678,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $endlessloop = 0; while ((strpos($Text, "[/open]")!== false) and (strpos($Text, "[open=") !== false) and (++$endlessloop < 20)) { $rnd = mt_rand(); - $Text = preg_replace("/\[open=(.*?)\](.*?)\[\/open\]/ism", - "
$1
$2
", - $Text); + $Text = preg_replace_callback("/\[open=(.*?)\](.*?)\[\/open\]/ism",'bbopentag',$Text); } -- cgit v1.2.3