From 80fe5a5e6099e7c937cd5dc034d0aa65991e3d2f Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Thu, 8 Feb 2024 14:30:22 +0700 Subject: [PATCH] Removed wbr() (#1387) --- index.php | 2 +- library/attach_mod/displaying_torrent.php | 2 +- library/includes/functions.php | 5 ----- library/includes/ucp/topic_watch.php | 6 +++--- library/includes/ucp/viewtorrent.php | 10 +++++----- modcp.php | 4 ++-- posting.php | 4 ++-- privmsg.php | 2 +- search.php | 2 +- src/Legacy/Atom.php | 5 ++--- tracker.php | 2 +- viewforum.php | 2 +- viewtopic.php | 4 ++-- 13 files changed, 22 insertions(+), 28 deletions(-) diff --git a/index.php b/index.php index 42121c302..92e3469a0 100644 --- a/index.php +++ b/index.php @@ -250,7 +250,7 @@ foreach ($cat_forums as $cid => $c) { $template->assign_block_vars('c.f.last', [ 'LAST_TOPIC_ID' => $f['last_topic_id'], 'LAST_TOPIC_TIP' => $f['last_topic_title'], - 'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)), + 'LAST_TOPIC_TITLE' => str_short($f['last_topic_title'], $last_topic_max_len), 'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']), 'LAST_POST_USER' => profile_url(['username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank']]), ]); diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index 928e8f577..e21badca0 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -88,7 +88,7 @@ if ($tor_auth_reg || $tor_auth_del) { $tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url; } -$display_name = wbr($t_data['topic_title']) . ' [' . $bb_cfg['server_name'] . '-' . $bt_topic_id . ']' . '.' . TORRENT_EXT; +$display_name = $t_data['topic_title'] . ' [' . $bb_cfg['server_name'] . '-' . $bt_topic_id . ']' . '.' . TORRENT_EXT; if (!$tor_reged) { $template->assign_block_vars('postrow.attach.tor_not_reged', [ diff --git a/library/includes/functions.php b/library/includes/functions.php index cd18c7720..01ff19822 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -790,11 +790,6 @@ function str_short($text, $max_length, $space = ' ') return $text ?? ''; } -function wbr($text, $max_word_length = HTML_WBR_LENGTH) -{ - return preg_replace("/([\w\->;:.,~!?(){}@#$%^*\/\\\\]{" . $max_word_length . "})/ui", '$1', $text); -} - function generate_user_info($row, bool $have_auth = IS_ADMIN): array { global $userdata, $lang, $images, $bb_cfg; diff --git a/library/includes/ucp/topic_watch.php b/library/includes/ucp/topic_watch.php index 310f6b578..1f5fadf8c 100644 --- a/library/includes/ucp/topic_watch.php +++ b/library/includes/ucp/topic_watch.php @@ -81,10 +81,10 @@ if ($watch_count > 0) { 'ROW_CLASS' => (!($i % 2)) ? 'row1' : 'row2', 'POST_ID' => $watch[$i]['topic_first_post_id'], 'TOPIC_ID' => $watch[$i]['topic_id'], - 'TOPIC_TITLE' => wbr(str_short($watch[$i]['topic_title'], 70)), - 'FULL_TOPIC_TITLE' => wbr($watch[$i]['topic_title']), + 'TOPIC_TITLE' => str_short($watch[$i]['topic_title'], 70), + 'FULL_TOPIC_TITLE' => $watch[$i]['topic_title'], 'U_TOPIC' => TOPIC_URL . $watch[$i]['topic_id'], - 'FORUM_TITLE' => wbr($watch[$i]['forum_name']), + 'FORUM_TITLE' => $watch[$i]['forum_name'], 'U_FORUM' => FORUM_URL . $watch[$i]['forum_id'], 'REPLIES' => $watch[$i]['topic_replies'], 'AUTHOR' => profile_url($watch[$i]), diff --git a/library/includes/ucp/viewtorrent.php b/library/includes/ucp/viewtorrent.php index 34ae15b51..33ccca610 100644 --- a/library/includes/ucp/viewtorrent.php +++ b/library/includes/ucp/viewtorrent.php @@ -49,7 +49,7 @@ foreach ($sql as $rowset) { if ($releasing) { foreach ($releasing as $i => $row) { - $topic_title = wbr($row['topic_title']); + $topic_title = $row['topic_title']; $template->assign_block_vars('released', [ 'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', @@ -69,7 +69,7 @@ if ($releasing) { if ($seeding) { foreach ($seeding as $i => $row) { - $topic_title = wbr($row['topic_title']); + $topic_title = $row['topic_title']; $template->assign_block_vars('seed', [ 'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', @@ -89,9 +89,9 @@ if ($seeding) { if ($leeching) { foreach ($leeching as $i => $row) { - $compl_size = ($row['remain'] && $row['size'] && $row['size'] > $row['remain']) ? ($row['size'] - $row['remain']) : 0; - $compl_perc = ($compl_size) ? floor($compl_size * 100 / $row['size']) : 0; - $topic_title = wbr($row['topic_title']); + $compl_size = ($row['remain'] && $row['size'] && ($row['size'] > $row['remain'])) ? ($row['size'] - $row['remain']) : 0; + $compl_perc = $compl_size ? floor($compl_size * 100 / $row['size']) : 0; + $topic_title = $row['topic_title']; $template->assign_block_vars('leech', [ 'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', diff --git a/modcp.php b/modcp.php index fc7d5696f..b7ac42a75 100644 --- a/modcp.php +++ b/modcp.php @@ -564,7 +564,7 @@ switch ($mode) { $template->assign_block_vars('postrow', [ 'ROW_CLASS' => $row_class, - 'POSTER_NAME' => wbr($poster), + 'POSTER_NAME' => $poster, 'POST_DATE' => $post_date, 'MESSAGE' => $message, 'CHECKBOX' => defined('BEGIN_CHECKBOX'), @@ -674,7 +674,7 @@ switch ($mode) { $template->assign_block_vars('userrow', [ 'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5', - 'USERNAME' => wbr($username), + 'USERNAME' => $username, 'POSTS' => $row['postings'], 'U_PROFILE' => ($id == GUEST_UID) ? "modcp.php?mode=ip&p=$post_id&t=$topic_id" : PROFILE_URL . $id, 'U_SEARCHPOSTS' => "search.php?search_author=1&uid=$id", diff --git a/posting.php b/posting.php index 8807b062e..240e5a73c 100644 --- a/posting.php +++ b/posting.php @@ -441,7 +441,7 @@ if ($refresh || $error_msg || ($submit && $topic_has_new_posts)) { $template->assign_vars([ 'TPL_PREVIEW_POST' => true, - 'TOPIC_TITLE' => wbr($preview_subject), + 'TOPIC_TITLE' => $preview_subject, 'POST_SUBJECT' => $preview_subject, 'POSTER_NAME' => $preview_username, 'POST_DATE' => bb_date(TIMENOW), @@ -618,7 +618,7 @@ $template->assign_vars([ 'PAGE_TITLE' => $page_title, 'POSTING_TYPE_TITLE' => $page_title, 'POSTING_TOPIC_ID' => ($mode != 'newtopic') ? $topic_id : '', - 'POSTING_TOPIC_TITLE' => ($mode != 'newtopic') ? wbr($post_info['topic_title']) : '', + 'POSTING_TOPIC_TITLE' => ($mode != 'newtopic') ? $post_info['topic_title'] : '', 'U_VIEW_FORUM' => FORUM_URL . $forum_id, 'USERNAME' => @$username, diff --git a/privmsg.php b/privmsg.php index cd1eaa6d4..8837d7d78 100644 --- a/privmsg.php +++ b/privmsg.php @@ -1074,7 +1074,7 @@ if ($mode == 'read') { $template->assign_vars([ 'TPL_PREVIEW_POST' => true, - 'TOPIC_TITLE' => wbr($preview_subject), + 'TOPIC_TITLE' => $preview_subject, 'POST_SUBJECT' => $preview_subject, 'MESSAGE_TO' => $to_username, 'MESSAGE_FROM' => $userdata['username'], diff --git a/search.php b/search.php index a31dc71ad..e12f6bdf1 100644 --- a/search.php +++ b/search.php @@ -801,7 +801,7 @@ else { 'FORUM_NAME' => $forum_name_html[$forum_id], 'TOPIC_ID' => $topic_id, 'HREF_TOPIC_ID' => $moved ? $topic['topic_moved_id'] : $topic['topic_id'], - 'TOPIC_TITLE' => wbr($topic['topic_title']), + 'TOPIC_TITLE' => $topic['topic_title'], 'IS_UNREAD' => $is_unread, 'TOPIC_ICON' => get_topic_icon($topic, $is_unread), 'PAGINATION' => $moved ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $topic['topic_replies'], $bb_cfg['posts_per_page']), diff --git a/src/Legacy/Atom.php b/src/Legacy/Atom.php index 20c6c3b19..bd2564fe5 100644 --- a/src/Legacy/Atom.php +++ b/src/Legacy/Atom.php @@ -149,7 +149,7 @@ class Atom @unlink($file_path); return false; } - if (self::create_atom($file_path, 'u', $user_id, wbr($username), $topics)) { + if (self::create_atom($file_path, 'u', $user_id, $username, $topics)) { return true; } @@ -210,8 +210,7 @@ class Atom if (\count($orig_word)) { $topic_title = preg_replace($orig_word, $replacement_word, $topic_title); } - $topic_title = wbr($topic_title); - $author_name = $topic['first_username'] ? wbr($topic['first_username']) : $lang['GUEST']; + $author_name = $topic['first_username'] ?: $lang['GUEST']; $last_time = $topic['topic_last_post_time']; if ($topic['topic_last_post_edit_time']) { $last_time = $topic['topic_last_post_edit_time']; diff --git a/tracker.php b/tracker.php index 3c38198b4..feccfe023 100644 --- a/tracker.php +++ b/tracker.php @@ -732,7 +732,7 @@ if ($allowed_forums) { 'FORUM_ID' => $forum_id, 'FORUM_NAME' => $forum_id ? $forum_name_html[$forum_id] : '', 'TOPIC_ID' => $tor['topic_id'], - 'TOPIC_TITLE' => wbr($tor['topic_title']), + 'TOPIC_TITLE' => $tor['topic_title'], 'TOPIC_TIME' => bb_date($tor['topic_time'], 'd-M-y') . ' · ' . delta_time($tor['topic_time']), 'POST_ID' => $tor['post_id'], 'POSTER_ID' => $poster_id, diff --git a/viewforum.php b/viewforum.php index 60655cd9a..715ba9074 100644 --- a/viewforum.php +++ b/viewforum.php @@ -444,7 +444,7 @@ foreach ($topic_rowset as $topic) { 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'HREF_TOPIC_ID' => $moved ? $topic['topic_moved_id'] : $topic['topic_id'], - 'TOPIC_TITLE' => wbr($topic['topic_title']), + 'TOPIC_TITLE' => $topic['topic_title'], 'TOPICS_SEPARATOR' => $separator, 'IS_UNREAD' => $is_unread, 'TOPIC_ICON' => get_topic_icon($topic, $is_unread), diff --git a/viewtopic.php b/viewtopic.php index c0022faf8..1f74ce78c 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -475,7 +475,7 @@ $template->assign_vars([ 'FORUM_NAME' => htmlCHR($forum_name), 'TOPIC_ID' => $topic_id, 'PAGE_TITLE' => $page_title, - 'TOPIC_TITLE' => wbr($topic_title), + 'TOPIC_TITLE' => $topic_title, 'PORNO_FORUM' => $t_data['allow_porno_topic'], 'REPLY_IMG' => $reply_img, 'SHOW_BOT_NICK' => $bb_cfg['show_bot_nick'], @@ -569,7 +569,7 @@ for ($i = 0; $i < $total_posts; $i++) { $post_date = bb_date($postrow[$i]['post_time'], $bb_cfg['post_date_format']); $max_post_time = max($max_post_time, $postrow[$i]['post_time']); $poster_posts = !$poster_guest ? $postrow[$i]['user_posts'] : ''; - $poster_from = ($postrow[$i]['user_from'] && !$poster_guest) ? wbr($postrow[$i]['user_from']) : ''; + $poster_from = ($postrow[$i]['user_from'] && !$poster_guest) ? $postrow[$i]['user_from'] : ''; $poster_joined = !$poster_guest ? $lang['JOINED'] . ': ' . bb_date($postrow[$i]['user_regdate'], 'Y-m-d H:i') : ''; $poster_longevity = !$poster_guest ? delta_time($postrow[$i]['user_regdate']) : ''; $post_id = $postrow[$i]['post_id'];