Exception handling for Bencode errors (#1237)

This commit is contained in:
Cønstantine Kovalensky 2023-12-20 21:37:47 +04:00 committed by GitHub
commit a953045aba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View file

@ -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'];
}