mirror of
https://github.com/django/django.git
synced 2025-10-27 07:36:08 +00:00
Fixed #4478 -- Added a catch for an error thrown by PIL when attempting to validate MS OLE files.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6096 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -393,7 +393,9 @@ class ImageField(FileField):
|
||||
from cStringIO import StringIO
|
||||
try:
|
||||
Image.open(StringIO(f.content))
|
||||
except IOError: # Python Imaging Library doesn't recognize it as an image
|
||||
except (IOError, OverflowError): # Python Imaging Library doesn't recognize it as an image
|
||||
# OverflowError is due to a bug in PIL with Python 2.4+ which can cause
|
||||
# it to gag on OLE files.
|
||||
raise ValidationError(ugettext(u"Upload a valid image. The file you uploaded was either not an image or a corrupted image."))
|
||||
return f
|
||||
|
||||
|
||||
Reference in New Issue
Block a user