diff --git a/src/NzbDrone.Core/Download/DownloadService.cs b/src/NzbDrone.Core/Download/DownloadService.cs index 6c6f67f0a..ccb590518 100644 --- a/src/NzbDrone.Core/Download/DownloadService.cs +++ b/src/NzbDrone.Core/Download/DownloadService.cs @@ -155,7 +155,9 @@ namespace NzbDrone.Core.Download throw; } + _logger.Trace("Downloaded {0} bytes from {1}", downloadedBytes.Length, link); _eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source, host, title, url.AbsoluteUri)); + return downloadedBytes; } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/Cardigann.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/Cardigann.cs index f86724a03..69540cf3e 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/Cardigann.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/Cardigann.cs @@ -189,6 +189,7 @@ namespace NzbDrone.Core.Indexers.Cardigann if (request.Url.Scheme == "magnet") { ValidateMagnet(request.Url.FullUri); + return Encoding.UTF8.GetBytes(request.Url.FullUri); } @@ -233,6 +234,8 @@ namespace NzbDrone.Core.Indexers.Cardigann throw; } + ValidateTorrent(downloadBytes); + return downloadBytes; } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs b/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs index 43927d995..fc69df97c 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs @@ -112,6 +112,8 @@ namespace NzbDrone.Core.Indexers.Definitions _logger.Error("Download failed"); } + ValidateTorrent(downloadBytes); + return downloadBytes; } } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs b/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs index 505a173e0..2460c7f3d 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs @@ -94,6 +94,8 @@ namespace NzbDrone.Core.Indexers.Definitions _logger.Error("Download failed"); } + ValidateTorrent(downloadBytes); + return downloadBytes; } } diff --git a/src/NzbDrone.Core/Indexers/Definitions/SpeedApp/SpeedAppBase.cs b/src/NzbDrone.Core/Indexers/Definitions/SpeedApp/SpeedAppBase.cs index eb8309205..b7ffde0d6 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/SpeedApp/SpeedAppBase.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/SpeedApp/SpeedAppBase.cs @@ -111,6 +111,7 @@ namespace NzbDrone.Core.Indexers.Definitions if (link.Scheme == "magnet") { ValidateMagnet(link.OriginalString); + return Encoding.UTF8.GetBytes(link.OriginalString); } @@ -164,6 +165,8 @@ namespace NzbDrone.Core.Indexers.Definitions throw; } + ValidateTorrent(torrentData); + return torrentData; } diff --git a/src/NzbDrone.Core/Indexers/TorrentIndexerBase.cs b/src/NzbDrone.Core/Indexers/TorrentIndexerBase.cs index b804c2903..dda66a713 100644 --- a/src/NzbDrone.Core/Indexers/TorrentIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/TorrentIndexerBase.cs @@ -26,6 +26,7 @@ namespace NzbDrone.Core.Indexers if (link.Scheme == "magnet") { ValidateMagnet(link.OriginalString); + return Encoding.UTF8.GetBytes(link.OriginalString); } @@ -78,6 +79,8 @@ namespace NzbDrone.Core.Indexers throw; } + ValidateTorrent(torrentData); + return torrentData; } @@ -85,5 +88,18 @@ namespace NzbDrone.Core.Indexers { MagnetLink.Parse(link); } + + protected void ValidateTorrent(byte[] torrentData) + { + try + { + Torrent.Load(torrentData); + } + catch + { + _logger.Trace("Invalid torrent file contents: {0}", Encoding.ASCII.GetString(torrentData)); + throw; + } + } } }