mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #24544 -- Fixed get_image_dimensions() on image buffers that Pillow fails to parse.
Thanks Steve Kossouho for the report and original patch.
This commit is contained in:
@@ -3,6 +3,7 @@ Utility functions for handling images.
|
||||
|
||||
Requires Pillow as you might imagine.
|
||||
"""
|
||||
import struct
|
||||
import zlib
|
||||
|
||||
from django.core.files import File
|
||||
@@ -63,6 +64,11 @@ def get_image_dimensions(file_or_path, close=False):
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
except struct.error as e:
|
||||
# Ignore PIL failing on a too short buffer when reads return
|
||||
# less bytes than expected. Skip and feed more data to the
|
||||
# parser (ticket #24544).
|
||||
pass
|
||||
if p.image:
|
||||
return p.image.size
|
||||
chunk_size *= 2
|
||||
|
||||
Reference in New Issue
Block a user