move substitution of new lines with <br> to the end of bbcode(). This will fix issue #1512.

This commit is contained in:
Mario
2021-02-15 08:20:42 +00:00
parent 50e9a12ca5
commit ed99392001

View File

@@ -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 <br /> 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('<br />', '<br />'), $Text);
if ($preserve_nl)
$Text = str_replace(array("\n", "\r"), array('', ''), $Text);
$Text = str_replace(array("\t", " "), array("&nbsp;&nbsp;&nbsp;&nbsp;", "&nbsp;&nbsp;"), $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 <br /> 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('<br />', '<br />'), $Text);
if ($preserve_nl)
$Text = str_replace(array("\n", "\r"), array('', ''), $Text);
call_hooks('bbcode', $Text);
return $Text;