Django

Code

Changeset 6096

Show
Ignore:
Timestamp:
09/11/07 08:13:35 (1 year ago)
Author:
russellm
Message:

Fixed #4478 -- Added a catch for an error thrown by PIL when attempting to validate MS OLE files.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/validators.py

    r6068 r6096  
    183183    try: 
    184184        Image.open(StringIO(content)) 
    185     except IOError: # Python Imaging Library doesn't recognize it as an image 
     185    except (IOError, OverflowError): # Python Imaging Library doesn't recognize it as an image 
     186        # OverflowError is due to a bug in PIL with Python 2.4+ which can cause  
     187        # it to gag on OLE files.  
    186188        raise ValidationError, _("Upload a valid image. The file you uploaded was either not an image or a corrupted image.") 
    187189 
  • django/trunk/django/newforms/fields.py

    r6068 r6096  
    394394        try: 
    395395            Image.open(StringIO(f.content)) 
    396         except IOError: # Python Imaging Library doesn't recognize it as an image 
     396        except (IOError, OverflowError): # Python Imaging Library doesn't recognize it as an image 
     397            # OverflowError is due to a bug in PIL with Python 2.4+ which can cause  
     398            # it to gag on OLE files.  
    397399            raise ValidationError(ugettext(u"Upload a valid image. The file you uploaded was either not an image or a corrupted image.")) 
    398400        return f