aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Browning <ayleph@thisshitistemp.com>2017-10-25 02:33:49 -0400
committerAndrew Browning <ayleph@thisshitistemp.com>2018-04-04 17:11:15 -0400
commit9a23a81671929212e535ae8171b0cba27c3a2067 (patch)
treeca7f24828652854ab2353b60c5c8959c5f506c5e
parentfee80cf134849b4d2984dff9bca241df9be0ab16 (diff)
downloadmediagoblin-9a23a81671929212e535ae8171b0cba27c3a2067.tar.lz
mediagoblin-9a23a81671929212e535ae8171b0cba27c3a2067.tar.xz
mediagoblin-9a23a81671929212e535ae8171b0cba27c3a2067.zip
Prevent video plugin from processing svg [#934]
Prior to the gstreamer-1.0 upgrade, the video processing engine included a check for excluded extensions which gstreamer might accept despite us not wanting to process them. In commit 91f5f5e, the check against EXCLUDED_EXT was removed. Since then, the video plugin has accepted and attempted to process svg files. This commit adds the check against EXCLUDED_EXTS into the sniff_handler function so that we can bail out on certain file extensions before the plugins tries to sniff the file type. The previous implementation excluded nef files, which appears to be a Nikon camera image. I've copied that forward to this code. I've also added a log message to indicate that we're purposefully refusing to process the file.
-rw-r--r--mediagoblin/media_types/video/processing.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py
index ca3087a2..3168c054 100644
--- a/mediagoblin/media_types/video/processing.py
+++ b/mediagoblin/media_types/video/processing.py
@@ -79,7 +79,17 @@ def sniffer(media_file):
return MEDIA_TYPE
+EXCLUDED_EXTS = ["nef", "svg"]
+
def sniff_handler(media_file, filename):
+ name, ext = os.path.splitext(filename)
+ clean_ext = ext.lower()[1:]
+
+ if clean_ext in EXCLUDED_EXTS:
+ # We don't handle this filetype, though gstreamer might think we can
+ _log.info('Refused to process {0} due to excluded extension'.format(filename))
+ return None
+
try:
return sniffer(media_file)
except: