From ed993920015cfae7f0e939b1733ab125c85e1dda Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 15 Feb 2021 08:20:42 +0000 Subject: move substitution of new lines with
to the end of bbcode(). This will fix issue #1512. --- include/bbcode.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index e1a5c7e47..dfc64f814 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1153,23 +1153,8 @@ function bbcode($Text, $options = []) { $Text = preg_replace_callback("/\[table\](.*?)\[\/table\]/ism",'bb_fixtable_lf',$Text); - // Convert new line chars to html
tags - - // nlbr seems to be hopelessly messed up - // $Text = nl2br($Text); - - // We'll emulate it. - - $Text = str_replace("\r\n", "\n", $Text); - $Text = str_replace(array("\r", "\n"), array('
', '
'), $Text); - - if ($preserve_nl) - $Text = str_replace(array("\n", "\r"), array('', ''), $Text); - - $Text = str_replace(array("\t", " "), array("    ", "  "), $Text); - // Check for [code] text if (strpos($Text,'[code]') !== false) { $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism", 'bb_code', $Text); @@ -1633,6 +1618,19 @@ function bbcode($Text, $options = []) { $Text = bb_replace_images($Text, $saved_images); + // Convert new line chars to html
tags + + // nlbr seems to be hopelessly messed up + // $Text = nl2br($Text); + + // We'll emulate it. + + $Text = str_replace("\r\n", "\n", $Text); + $Text = str_replace(array("\r", "\n"), array('
', '
'), $Text); + + if ($preserve_nl) + $Text = str_replace(array("\n", "\r"), array('', ''), $Text); + call_hooks('bbcode', $Text); return $Text; -- cgit v1.2.3