diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2007-09-11 13:13:35 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2007-09-11 13:13:35 +0000 |
| commit | 7115465afa549955ec446638e0d73b597e6ffd20 (patch) | |
| tree | 515651e22fb117fe1c721b3ebca761eb82b1f25c /django/newforms/fields.py | |
| parent | 2cf419d9ed1d9ed188413df5113161486ca8f746 (diff) | |
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
Diffstat (limited to 'django/newforms/fields.py')
| -rw-r--r-- | django/newforms/fields.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/newforms/fields.py b/django/newforms/fields.py index 658eea6fba..a98779a334 100644 --- a/django/newforms/fields.py +++ b/django/newforms/fields.py @@ -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 |
