django-image-cropping
django-image-cropping copied to clipboard
Handle DecompressionBombError when uploading a large image
Steps to reproduce
- run the example project
- try to upload a large image (for example this 16000x16000 gif) using ModelForm
Expected result
The form should be invalid and user should be notified of error (invalid file)
Actual result
Since Pillow throws a DecompressionBombError instead of an AttributeError, this won't be caught in get_attrs() when trying to determine the image size. The view returns an error 500 instead of showing the invalid form. The user has no chance to see what's going wrong.
Solution
When rendering the widget, any exception from the backend should be handled. This is what this PR does.
Notes
This PR is based on my other PR (#184), in order to let the workflow/automated test run.