diff --git a/library/ajax/view_torrent.php b/library/ajax/view_torrent.php index faa8851a1..af3b5ef5d 100644 --- a/library/ajax/view_torrent.php +++ b/library/ajax/view_torrent.php @@ -28,7 +28,10 @@ if (!file_exists($filename) || !$file_contents = file_get_contents($filename)) { $this->ajax_die($lang['ERROR_NO_ATTACHMENT'] . "\n\n" . htmlCHR($filename)); } -if (!$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY)) { +try { + $tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY); +} +catch (Exception) { return $lang['TORFILE_INVALID']; } diff --git a/library/includes/file_list_v2.php b/library/includes/file_list_v2.php index 5f530fab4..240298c52 100644 --- a/library/includes/file_list_v2.php +++ b/library/includes/file_list_v2.php @@ -60,7 +60,10 @@ if ($bb_cfg['flist_max_files']) { } } -if (!$torrent = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY)) { +try { + $torrent = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY); +} +catch (Exception) { http_response_code(410); die($lang['TORFILE_INVALID']); } diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php index ca48ab77a..dbbb8ec35 100644 --- a/src/Legacy/Torrent.php +++ b/src/Legacy/Torrent.php @@ -317,7 +317,10 @@ class Torrent $file_contents = file_get_contents($filename); - if (!$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY)) { + try { + $tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY); + } + catch (Exception ) { self::torrent_error_exit($lang['TORFILE_INVALID']); } @@ -559,7 +562,10 @@ class Torrent // Torrent decoding $file_contents = file_get_contents($filename); - if (!$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY)) { + try { + $tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY); + } + catch (Exception) { bb_die($lang['TORFILE_INVALID']); }