Author: russellm
Date: 2007-09-11 08:13:35 -0500 (Tue, 11 Sep 2007)
New Revision: 6096
Modified:
django/trunk/django/core/validators.py
django/trunk/django/newforms/fields.py
Log:
Fixed #4478 -- Added a catch for an error thrown by PIL when attempting to
validate MS OLE files.
Modified: django/trunk/django/core/validators.py
===================================================================
--- django/trunk/django/core/validators.py 2007-09-11 11:46:34 UTC (rev
6095)
+++ django/trunk/django/core/validators.py 2007-09-11 13:13:35 UTC (rev
6096)
@@ -182,7 +182,9 @@
raise ValidationError, _("No file was submitted. Check the encoding
type on the form.")
try:
Image.open(StringIO(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, _("Upload a valid image. The file you uploaded
was either not an image or a corrupted image.")
def isValidImageURL(field_data, all_data):
Modified: django/trunk/django/newforms/fields.py
===================================================================
--- django/trunk/django/newforms/fields.py 2007-09-11 11:46:34 UTC (rev
6095)
+++ django/trunk/django/newforms/fields.py 2007-09-11 13:13:35 UTC (rev
6096)
@@ -393,7 +393,9 @@
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---