From b1bd25d32a46aa8f490d9a7871071cc58c15f204 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Wed, 15 Nov 2023 21:36:40 +0700 Subject: [PATCH] Replaced some html_entity_decode to engine's built-in function (#1105) --- library/attach_mod/displaying_torrent.php | 2 +- library/includes/init_bb.php | 12 +++++++----- tracker.php | 2 +- viewforum.php | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index 965ec08a5..e7286b1e8 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -145,7 +145,7 @@ if ($tor_reged && $tor_info) { // Magnet link $user_passkey = \TorrentPier\Legacy\Torrent::getPasskey($bt_user_id); - $tor_magnet = create_magnet($tor_info['info_hash'], $tor_info['info_hash_v2'], $user_passkey, html_entity_decode($t_data['topic_title'], ENT_QUOTES, 'UTF-8')); + $tor_magnet = create_magnet($tor_info['info_hash'], $tor_info['info_hash_v2'], $user_passkey, html_ent_decode($t_data['topic_title'])); // ratio limits $min_ratio_dl = $bb_cfg['bt_min_ratio_allow_dl_tor']; diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index c7bd4fd49..4ad0171af 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -336,14 +336,16 @@ function commify(?float $num, int $decimals = 0, ?string $decimal_separator = '. } /** - * @param $txt - * @param int $quote_style - * @param string $charset + * Convert HTML entities to their corresponding characters + * + * @param string $string + * @param int $flags + * @param string|null $encoding * @return string */ -function html_ent_decode($txt, $quote_style = ENT_QUOTES, $charset = 'UTF-8') +function html_ent_decode(string $string, int $flags = ENT_QUOTES, ?string $encoding = 'UTF-8'): string { - return (string)html_entity_decode($txt, $quote_style, $charset); + return html_entity_decode($string, $flags, $encoding); } /** diff --git a/tracker.php b/tracker.php index 02a368445..db548cb56 100644 --- a/tracker.php +++ b/tracker.php @@ -702,7 +702,7 @@ if ($allowed_forums) { $s_last = $tor['seeder_last_seen']; $att_id = $tor['attach_id']; $size = $tor['size']; - $tor_magnet = create_magnet($tor['info_hash'], $tor['info_hash_v2'], \TorrentPier\Legacy\Torrent::getPasskey($user_id), html_entity_decode($tor['topic_title'], ENT_QUOTES, 'UTF-8')); + $tor_magnet = create_magnet($tor['info_hash'], $tor['info_hash_v2'], \TorrentPier\Legacy\Torrent::getPasskey($user_id), html_ent_decode($tor['topic_title'])); $compl = $tor['complete_count']; $dl_sp = ($dl) ? humn_size($dl, 0, 'KB') . '/s' : '0 KB/s'; $ul_sp = ($ul) ? humn_size($ul, 0, 'KB') . '/s' : '0 KB/s'; diff --git a/viewforum.php b/viewforum.php index 8cc1914a7..f4ff396bc 100644 --- a/viewforum.php +++ b/viewforum.php @@ -469,7 +469,7 @@ foreach ($topic_rowset as $topic) { )); if (isset($topic['tor_size'])) { - $tor_magnet = create_magnet($topic['info_hash'], $topic['info_hash_v2'], $topic['auth_key'], html_entity_decode($topic['topic_title'], ENT_QUOTES, 'UTF-8')); + $tor_magnet = create_magnet($topic['info_hash'], $topic['info_hash_v2'], $topic['auth_key'], html_ent_decode($topic['topic_title'])); $template->assign_block_vars('t.tor', array( 'SEEDERS' => (int)$topic['seeders'],