diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_profile.php | 2 | ||||
-rw-r--r-- | phpBB/includes/bbcode.php | 7 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 16 | ||||
-rw-r--r-- | phpBB/includes/functions_admin.php | 4 | ||||
-rw-r--r-- | phpBB/includes/functions_posting.php | 6 | ||||
-rw-r--r-- | phpBB/includes/functions_privmsgs.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions_profile_fields.php | 4 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_post.php | 6 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_queue.php | 4 | ||||
-rwxr-xr-x | phpBB/includes/mcp/mcp_reports.php | 4 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_topic.php | 2 | ||||
-rwxr-xr-x | phpBB/includes/mcp/mcp_warn.php | 5 | ||||
-rw-r--r-- | phpBB/includes/message_parser.php | 7 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_attachments.php | 2 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm_viewmessage.php | 6 |
15 files changed, 45 insertions, 32 deletions
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 00f8d64acb..c2fde25eb5 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -925,7 +925,7 @@ class acp_profile $lang_options[1]['lang_iso'] = $this->lang_defs['id'][$default_lang_id]; $lang_options[1]['fields'][$field] = array( 'TITLE' => $user->lang['CP_' . strtoupper($field)], - 'FIELD' => '<dd>' . ((is_array($cp->vars[$field])) ? implode('<br />', $cp->vars[$field]) : str_replace("\n", '<br />', $cp->vars[$field])) . '</dd>' + 'FIELD' => '<dd>' . ((is_array($cp->vars[$field])) ? implode('<br />', $cp->vars[$field]) : bbcode_nl2br($cp->vars[$field])) . '</dd>' ); if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN'])) diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index e2d8b7cde4..4b8ad62a51 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -156,10 +156,9 @@ class bbcode while ($row = $db->sql_fetchrow($result)) { // To circumvent replacing newlines with <br /> for the generated html, - // we just remove newlines here. We do not do this within the admin panel to - // let the admin lay out his html code nicely - $row['bbcode_tpl'] = str_replace(array("\n", "\r"), '', $row['bbcode_tpl']); - $row['second_pass_replace'] = str_replace(array("\n", "\r"), '', $row['second_pass_replace']); + // we use carriage returns here. They are later changed back to newlines + $row['bbcode_tpl'] = str_replace("\n", "\r", $row['bbcode_tpl']); + $row['second_pass_replace'] = str_replace("\n", "\r", $row['second_pass_replace']); $rowset[$row['bbcode_id']] = $row; } 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", '<br />', $text); - + $text = bbcode_nl2br($text); $text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES)); return $text; @@ -2814,6 +2813,17 @@ function censor_text($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 <br /> so now revert that + $text = str_replace(array("\n", "\r"), array('<br />', "\n"), $text); + return $text; +} + +/** * Smiley processing */ function smiley_text($text, $force_option = false) @@ -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", '<br />', censor_text($attachment['attach_comment'])); + $comment = bbcode_nl2br(censor_text($attachment['attach_comment'])); $block_array += array( 'UPLOAD_ICON' => $upload_icon, diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 29d52406da..4dfd58e28c 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2429,11 +2429,11 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id // If within the admin panel we do not censor text out if (defined('IN_ADMIN')) { - $log[$i]['action'] = str_replace("\n", '<br />', $log[$i]['action']); + $log[$i]['action'] = bbcode_nl2br($log[$i]['action']); } else { - $log[$i]['action'] = str_replace("\n", '<br />', censor_text($log[$i]['action'])); + $log[$i]['action'] = bbcode_nl2br(censor_text($log[$i]['action'])); } } else diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index b246a72daf..222f9a3843 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1021,8 +1021,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $decoded_message = $message; decode_message($decoded_message, $row['bbcode_uid']); - $decoded_message = censor_text($decoded_message); - $decoded_message = str_replace("\n", "<br />", $decoded_message); + $decoded_message = bbcode_nl2br($decoded_message); } if ($row['bbcode_bitfield']) @@ -1030,8 +1029,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } - $message = str_replace("\n", '<br />', $message); - + $message = bbcode_nl2br($message); $message = smiley_text($message, !$row['enable_smilies']); if (!empty($attachments[$row['post_id']])) diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 2a8990b607..ac6f4a0afe 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1774,13 +1774,13 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode $message = $row['message_text']; $message = censor_text($message); - $message = str_replace("\n", '<br />', $message); if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } + $message = bbcode_nl2br($message); $message = smiley_text($message, !$row['enable_smilies']); $subject = censor_text($subject); diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index f3ebe429cd..cbad80e28e 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -176,7 +176,7 @@ class custom_profile if (!empty($field_data['field_validation']) && $field_data['field_validation'] != '.*') { - $field_validate = ($field_type == FIELD_STRING) ? $field_value : str_replace("\n", ' ', $field_value); + $field_validate = ($field_type == FIELD_STRING) ? $field_value : bbcode_nl2br($field_value); if (!preg_match('#^' . str_replace('\\\\', '\\', $field_data['field_validation']) . '$#i', $field_validate)) { return 'FIELD_INVALID_CHARS'; @@ -462,7 +462,7 @@ class custom_profile $value = make_clickable($value); $value = censor_text($value); - $value = str_replace("\n", '<br />', $value); + $value = bbcode_nl2br($value); return $value; break; diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index 698bcc8dd6..32fb572d3f 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -112,13 +112,15 @@ function mcp_post_details($id, $mode, $action) // Process message, leave it uncensored $message = $post_info['post_text']; - $message = str_replace("\n", '<br />', $message); + if ($post_info['bbcode_bitfield']) { include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); $bbcode = new bbcode($post_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); } + + $message = bbcode_nl2br($message); $message = smiley_text($message); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) @@ -261,7 +263,7 @@ function mcp_post_details($id, $mode, $action) 'U_REPORTER' => ($row['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']) : '', 'USER_NOTIFY' => ($row['user_notify']) ? true : false, 'REPORT_TIME' => $user->format_date($row['report_time']), - 'REPORT_TEXT' => str_replace("\n", '<br />', trim($row['report_text']))) + 'REPORT_TEXT' => bbcode_nl2br(trim($row['report_text'])))) ); } while ($row = $db->sql_fetchrow($result)); diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index f82a99c2c3..0d2ea76498 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -119,13 +119,15 @@ class mcp_queue // Process message, leave it uncensored $message = $post_info['post_text']; - $message = str_replace("\n", '<br />', $message); + if ($post_info['bbcode_bitfield']) { include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); $bbcode = new bbcode($post_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); } + + $message = bbcode_nl2br($message); $message = smiley_text($message); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 9a06b3bbf2..9528eec33b 100755 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -128,13 +128,15 @@ class mcp_reports // Process message, leave it uncensored $message = $post_info['post_text']; - $message = str_replace("\n", '<br />', $message); + if ($post_info['bbcode_bitfield']) { include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); $bbcode = new bbcode($post_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); } + + $message = bbcode_nl2br($message); $message = smiley_text($message); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index a5bfba23fe..1002b1c918 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -175,13 +175,13 @@ function mcp_topic_view($id, $mode, $action) { $message = $row['post_text']; $post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_info['topic_title']; - $message = str_replace("\n", '<br />', $message); if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } + $message = bbcode_nl2br($message); $message = smiley_text($message); if (!empty($attachments[$row['post_id']])) diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 915df898f7..892929539f 100755 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -253,8 +253,7 @@ class mcp_warn // We want to make the message available here as a reminder // Parse the message and subject - $message = $user_row['post_text']; - $message = str_replace("\n", '<br />', censor_text($message)); + $message = censor_text($user_row['post_text']); // Second parse bbcode here if ($user_row['bbcode_bitfield']) @@ -265,7 +264,7 @@ class mcp_warn $bbcode->bbcode_second_pass($message, $user_row['bbcode_uid'], $user_row['bbcode_bitfield']); } - // Always process smilies after parsing bbcodes + $message = bbcode_nl2br($message); $message = smiley_text($message); // Generate the appropriate user information for the user we are looking at diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 65ffee8dd0..d2e54e1404 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1138,6 +1138,9 @@ class parse_message extends bbcode_firstpass $this->parse($allow_bbcode, $allow_magic_url, $allow_smilies, $this->allow_img_bbcode, $this->allow_flash_bbcode, $this->allow_quote_bbcode, $this->allow_url_bbcode, true); } + // Replace naughty words such as farty pants + $this->message = censor_text($this->message); + // Parse BBcode if ($allow_bbcode) { @@ -1147,11 +1150,9 @@ class parse_message extends bbcode_firstpass $this->bbcode_second_pass($this->message, $this->bbcode_uid); } + $this->message = bbcode_nl2br($this->message); $this->message = smiley_text($this->message, !$allow_smilies); - // Replace naughty words such as farty pants - $this->message = str_replace("\n", '<br />', censor_text($this->message)); - if (!$update_this_message) { unset($this->message); diff --git a/phpBB/includes/ucp/ucp_attachments.php b/phpBB/includes/ucp/ucp_attachments.php index 895cb51020..b20e4a55ed 100644 --- a/phpBB/includes/ucp/ucp_attachments.php +++ b/phpBB/includes/ucp/ucp_attachments.php @@ -121,7 +121,7 @@ class ucp_attachments $template->assign_block_vars('attachrow', array( 'ROW_NUMBER' => $row_count + ($start + 1), 'FILENAME' => $row['real_filename'], - 'COMMENT' => str_replace("\n", '<br />', $row['attach_comment']), + 'COMMENT' => bbcode_nl2br($row['attach_comment']), 'EXTENSION' => $row['extension'], 'SIZE' => ($row['filesize'] >= 1048576) ? ($row['filesize'] >> 20) . ' ' . $user->lang['MB'] : (($row['filesize'] >= 1024) ? ($row['filesize'] >> 10) . ' ' . $user->lang['KB'] : $row['filesize'] . ' ' . $user->lang['BYTES']), 'DOWNLOAD_COUNT' => $row['download_count'], diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index b980774403..492ce08b45 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -56,8 +56,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) $user_info = get_user_information($author_id, $message_row); // Parse the message and subject - $message = $message_row['message_text']; - $message = str_replace("\n", '<br />', censor_text($message)); + $message = censor_text($message_row['message_text']); // Second parse bbcode here if ($message_row['bbcode_bitfield']) @@ -66,6 +65,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) } // Always process smilies after parsing bbcodes + $message = bbcode_nl2br($message); $message = smiley_text($message); // Replace naughty words such as farty pants @@ -142,7 +142,6 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) if ($signature) { $signature = censor_text($signature); - $signature = str_replace("\n", '<br />', censor_text($signature)); if ($user_info['user_sig_bbcode_bitfield']) { @@ -155,6 +154,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) $bbcode->bbcode_second_pass($signature, $user_info['user_sig_bbcode_uid'], $user_info['user_sig_bbcode_bitfield']); } + $signature = bbcode_nl2br($signature); $signature = smiley_text($signature); } |