# HG changeset patch # User neko259 # Date 2017-01-10 22:04:41 # Node ID 1bcad2dd3aa420230111e15fd02e3f569166d659 # Parent 7b11aedb2e783bf84a2ba16776fa52f85d150060 Raise an error whena decompression bomb is launched to the thumbs generator diff --git a/boards/thumbs.py b/boards/thumbs.py --- a/boards/thumbs.py +++ b/boards/thumbs.py @@ -25,6 +25,8 @@ def generate_thumb(img, thumb_size, form (this format will be used for the generated thumbnail, too) """ + Image.warnings.simplefilter('error', Image.DecompressionBombWarning) + img.seek(0) # see http://code.djangoproject.com/ticket/8222 for details image = Image.open(img) @@ -212,4 +214,4 @@ class ImageWithThumbsField(ImageField): thumb_height_ratio = int(original_height * scale_ratio) setattr(instance, thumb_width_field, thumb_width_ratio) - setattr(instance, thumb_height_field, thumb_height_ratio) \ No newline at end of file + setattr(instance, thumb_height_field, thumb_height_ratio)