File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,11 @@ class ThumbnailError(Exception):
67
67
class Thumbnailer :
68
68
FORMATS = {"image/jpeg" : "JPEG" , "image/png" : "PNG" }
69
69
70
+ # Which image formats we allow Pillow to open.
71
+ # This should intentionally be kept restrictive, because the decoder of any
72
+ # format in this list becomes part of our trusted computing base.
73
+ PILLOW_FORMATS = ("jpeg" , "png" , "webp" , "gif" )
74
+
70
75
@staticmethod
71
76
def set_limits (max_image_pixels : int ) -> None :
72
77
Image .MAX_IMAGE_PIXELS = max_image_pixels
@@ -76,7 +81,7 @@ def __init__(self, input_path: str):
76
81
self ._closed = False
77
82
78
83
try :
79
- self .image = Image .open (input_path )
84
+ self .image = Image .open (input_path , formats = self . PILLOW_FORMATS )
80
85
except OSError as e :
81
86
# If an error occurs opening the image, a thumbnail won't be able to
82
87
# be generated.
You can’t perform that action at this time.
0 commit comments