Corrupted image upload exception

This commit is contained in:
adi 2016-08-25 21:06:00 +02:00
parent 8f140679aa
commit 9dba8c0abd
3 changed files with 14 additions and 9 deletions

View file

@ -327,6 +327,10 @@ $('.markdownx').on('markdownx.update', function(e, response) {
# Changelog
###### v1.6.3
* Corrupted image upload exception
###### v1.6.2
* Runtest template fix

View file

@ -42,12 +42,13 @@ class ImageForm(forms.Form):
return filename
def clean(self):
upload = self.cleaned_data['image']
content_type = upload.content_type
if content_type in MARKDOWNX_UPLOAD_CONTENT_TYPES:
if upload._size > MARKDOWNX_UPLOAD_MAX_SIZE:
raise forms.ValidationError(_('Please keep filesize under %(max)s. Current filesize %(current)s') % {'max':filters.filesizeformat(MARKDOWNX_UPLOAD_MAX_SIZE), 'current':filters.filesizeformat(upload._size)})
else:
raise forms.ValidationError(_('File type is not supported'))
upload = self.cleaned_data.get('image')
if upload:
content_type = upload.content_type
if content_type in MARKDOWNX_UPLOAD_CONTENT_TYPES:
if upload._size > MARKDOWNX_UPLOAD_MAX_SIZE:
raise forms.ValidationError(_('Please keep filesize under %(max)s. Current filesize %(current)s') % {'max':filters.filesizeformat(MARKDOWNX_UPLOAD_MAX_SIZE), 'current':filters.filesizeformat(upload._size)})
else:
raise forms.ValidationError(_('File type is not supported'))
return upload
return upload

View file

@ -10,7 +10,7 @@ def get_requirements():
setup(
name='django-markdownx',
version='1.6.2',
version='1.6.3',
packages=find_packages(),
include_package_data=True,
description='django-markdownx is a Markdown editor built for Django.',