mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 05:13:54 -07:00
Exception handling for Bencode errors (#1239)
This commit is contained in:
parent
a953045aba
commit
586fc0b563
3 changed files with 5 additions and 7 deletions
|
@ -30,9 +30,9 @@ if (!file_exists($filename) || !$file_contents = file_get_contents($filename)) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
|
$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
|
||||||
}
|
} catch (Exception) {
|
||||||
catch (Exception) {
|
$this->response['html'] = $lang['TORFILE_INVALID'];
|
||||||
return $lang['TORFILE_INVALID'];
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$torrent = new TorrentPier\Legacy\TorrentFileList($tor);
|
$torrent = new TorrentPier\Legacy\TorrentFileList($tor);
|
||||||
|
|
|
@ -62,8 +62,7 @@ if ($bb_cfg['flist_max_files']) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$torrent = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
|
$torrent = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
|
||||||
}
|
} catch (Exception) {
|
||||||
catch (Exception) {
|
|
||||||
http_response_code(410);
|
http_response_code(410);
|
||||||
die($lang['TORFILE_INVALID']);
|
die($lang['TORFILE_INVALID']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -564,8 +564,7 @@ class Torrent
|
||||||
$file_contents = file_get_contents($filename);
|
$file_contents = file_get_contents($filename);
|
||||||
try {
|
try {
|
||||||
$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
|
$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
|
||||||
}
|
} catch (Exception) {
|
||||||
catch (Exception) {
|
|
||||||
bb_die($lang['TORFILE_INVALID']);
|
bb_die($lang['TORFILE_INVALID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue