django-image-cropping icon indicating copy to clipboard operation
django-image-cropping copied to clipboard

Handle DecompressionBombError when uploading a large image

Open chrisv2 opened this issue 1 year ago • 0 comments

Steps to reproduce

  1. run the example project
  2. 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.

chrisv2 avatar Oct 09 '24 19:10 chrisv2