mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 13:24:01 -07:00
Exception handling for Bencode errors (#1237)
This commit is contained in:
parent
508f73933a
commit
a953045aba
3 changed files with 16 additions and 4 deletions
|
@ -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));
|
$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'];
|
return $lang['TORFILE_INVALID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
http_response_code(410);
|
||||||
die($lang['TORFILE_INVALID']);
|
die($lang['TORFILE_INVALID']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,10 @@ class Torrent
|
||||||
|
|
||||||
$file_contents = file_get_contents($filename);
|
$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']);
|
self::torrent_error_exit($lang['TORFILE_INVALID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,7 +562,10 @@ class Torrent
|
||||||
|
|
||||||
// Torrent decoding
|
// Torrent decoding
|
||||||
$file_contents = file_get_contents($filename);
|
$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']);
|
bb_die($lang['TORFILE_INVALID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue