Fixing check_filetype...
authorChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 7 Jun 2011 05:36:24 +0000 (00:36 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 7 Jun 2011 05:36:24 +0000 (00:36 -0500)
We need to check the first part of the guess_type returned tuple, and
also this try: except: doesn't belong here, so killing.

mediagoblin/submit/security.py

index 5a06a499683058cb0809c85f29c11e5ab400a954..b2cb6d88a6acddfecbf96e1c88dac40ade80a352 100644 (file)
 
 from mimetypes import guess_type
 
-from Image import open as image_open
 
 ALLOWED = ['image/jpeg', 'image/png', 'image/tiff', 'image/gif']
 
 def check_filetype(posted_file):
-    if not guess_type(posted_file.filename) in ALLOWED:
-        return False
-
-    # TODO: This should be handled by the processing stage.  We should
-    # handle error detection there.
-    try:
-        image = image_open(posted_file.file)
-    except IOError:
+    if not guess_type(posted_file.filename)[0] in ALLOWED:
         return False
 
     return True