diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2016-03-16 20:40:38 +0100 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2016-03-16 20:40:38 +0100 |
commit | e0d68a962b3ee2eb16487bb82f91cca0d63a405f (patch) | |
tree | c41c5068397d696e50f66281ec5e1f98be1ac584 | |
parent | 3449357c142cf2891ae359a06a848516f5e7b8f9 (diff) | |
parent | e7cc82fdfb889493fbf9b56a32393019c78ccd72 (diff) | |
download | AntennaPod-e0d68a962b3ee2eb16487bb82f91cca0d63a405f.zip |
Merge pull request #1698 from mfietz/issue/1503-file-type-error
Downloader: Check content type for media
3 files changed, 12 insertions, 1 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java index ec84440ec..2b26f58c0 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java @@ -124,6 +124,15 @@ public class HttpDownloader extends Downloader { throw e; } } + + if(request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) { + String contentType = response.header("Content-Type"); + if(!contentType.startsWith("audio/") && !contentType.startsWith("video/")) { + onFail(DownloadError.ERROR_FILE_TYPE, null); + return; + } + } + responseBody = response.body(); String contentEncodingHeader = response.header("Content-Encoding"); boolean isGzip = false; diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/DownloadError.java b/core/src/main/java/de/danoeh/antennapod/core/util/DownloadError.java index 602c221bf..d3f6c6b79 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/DownloadError.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/DownloadError.java @@ -19,7 +19,8 @@ public enum DownloadError { ERROR_UNKNOWN_HOST(11, R.string.download_error_unknown_host), ERROR_REQUEST_ERROR(12, R.string.download_error_request_error), ERROR_DB_ACCESS_ERROR(13, R.string.download_error_db_access), - ERROR_UNAUTHORIZED(14, R.string.download_error_unauthorized); + ERROR_UNAUTHORIZED(14, R.string.download_error_unauthorized), + ERROR_FILE_TYPE(15, R.string.download_error_file_type_type); private final int code; private final int resId; diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 863dea423..8d948f5e6 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -178,6 +178,7 @@ <string name="download_error_connection_error">Connection Error</string> <string name="download_error_unknown_host">Unknown Host</string> <string name="download_error_unauthorized">Authentication Error</string> + <string name="download_error_file_type_type">File Type Error</string> <string name="cancel_all_downloads_label">Cancel all downloads</string> <string name="download_canceled_msg">Download canceled</string> <string name="download_canceled_autodownload_enabled_msg">Download canceled\nDisabled <i>Auto Download</i> for this item</string> |