Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle DecompressionBombError when uploading a large image #185

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

chrisv2
Copy link
Contributor

@chrisv2 chrisv2 commented Oct 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant