mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +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:
		| @@ -182,7 +182,9 @@ def isValidImage(field_data, all_data): | ||||
|         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): | ||||
|   | ||||
| @@ -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