Ticket #934: 0001-Prevent-video-plugin-from-processing-svg-934.patch

File 0001-Prevent-video-plugin-from-processing-svg-934.patch, 1.8 KB (added by ayleph, 7 years ago)
  • mediagoblin/media_types/video/processing.py

    From 0be46858aea5fcb2eee549bfd2730bc577b2a2a4 Mon Sep 17 00:00:00 2001
    From: Andrew Browning <ayleph@thisshitistemp.com>
    Date: Wed, 25 Oct 2017 02:33:49 -0400
    Subject: [PATCH] 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.
    ---
     mediagoblin/media_types/video/processing.py | 10 ++++++++++
     1 file changed, 10 insertions(+)
    
    diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py
    index ca3087a2..3168c054 100644
    a b def sniffer(media_file):  
    7979    return MEDIA_TYPE
    8080
    8181
     82EXCLUDED_EXTS = ["nef", "svg"]
     83
    8284def sniff_handler(media_file, filename):
     85    name, ext = os.path.splitext(filename)
     86    clean_ext = ext.lower()[1:]
     87
     88    if clean_ext in EXCLUDED_EXTS:
     89        # We don't handle this filetype, though gstreamer might think we can
     90        _log.info('Refused to process {0} due to excluded extension'.format(filename))
     91        return None
     92
    8393    try:
    8494        return sniffer(media_file)
    8595    except: