From d104d3d969d2fbc77f1004e0e5369e8c0c15738f Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 19 Aug 2007 13:40:53 +0000 Subject: - BBCode parsing order should ALWAYS be censor_text(), bbcode_secon_pass(), bbcode_nl2br(), smiley_text(), parse_attachments() - using \r on custom bbcodes to allow line breaks [Bug #10758] git-svn-id: file:///svn/phpbb/trunk@8050 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ab30aba48d..0f92a2f8ba 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2571,8 +2571,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags) $bbcode->bbcode_second_pass($text, $uid); } - $text = str_replace("\n", '
', $text); - + $text = bbcode_nl2br($text); $text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES)); return $text; @@ -2813,6 +2812,17 @@ function censor_text($text) return $text; } +/** +* custom version of nl2br which takes custom BBCodes into account +*/ +function bbcode_nl2br($text) +{ + // custom BBCodes might contain carriage returns so they + // are not converted into
so now revert that + $text = str_replace(array("\n", "\r"), array('
', "\n"), $text); + return $text; +} + /** * Smiley processing */ @@ -2955,7 +2965,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, $size_lang = ($filesize >= 1048576) ? $user->lang['MB'] : ( ($filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] ); $filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize); - $comment = str_replace("\n", '
', censor_text($attachment['attach_comment'])); + $comment = bbcode_nl2br(censor_text($attachment['attach_comment'])); $block_array += array( 'UPLOAD_ICON' => $upload_icon, -- cgit v1.2.1