From 8aa10a0746a6915ff3fef76ce0c24da40572c9d9 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sun, 26 May 2013 21:56:39 +0100 Subject: [PATCH] Add mkvinfo check for bad files before moving into place --- .../DownloadDispatcher/Source/Plugin/TV.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php b/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php index d98a14f..9b3b91e 100644 --- a/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php +++ b/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php @@ -261,7 +261,21 @@ class DownloadDispatcher_Source_Plugin_TV extends DownloadDispatcher_Source_Plug throw new DownloadDispatcher_Exception_UnacceptableContent($source_file); } + } + + case 'mkv': { + // Verify that the file isn't a fake + $safe_source_file = escapeshellarg($source_file); + $command = "mkvinfo {$safe_source_file}"; + DownloadDispatcher_LogEntry::debug($this->log, "Verifying '{$source_file}' contents with command: {$command}"); + list($code, $output, $error) = DownloadDispatcher_ForegroundTask::execute($command, $source_dir); + if ($code != 0) { + DownloadDispatcher_LogEntry::warning($this->log, "Failed to parse contents of '{$source_dir}/{$source_file}'."); + throw new DownloadDispatcher_Exception_UnacceptableContent($source_file); + } + } // continue into the next case + default: { DownloadDispatcher_LogEntry::info($this->log, "Copying '{$source_file}' to '{$destination_dir}'."); $result = copy("{$source_dir}/{$source_file}", "{$destination_dir}/{$source_file}");