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):
6767class Thumbnailer :
6868 FORMATS = {"image/jpeg" : "JPEG" , "image/png" : "PNG" }
6969
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+
7075 @staticmethod
7176 def set_limits (max_image_pixels : int ) -> None :
7277 Image .MAX_IMAGE_PIXELS = max_image_pixels
@@ -76,7 +81,7 @@ def __init__(self, input_path: str):
7681 self ._closed = False
7782
7883 try :
79- self .image = Image .open (input_path )
84+ self .image = Image .open (input_path , formats = self . PILLOW_FORMATS )
8085 except OSError as e :
8186 # If an error occurs opening the image, a thumbnail won't be able to
8287 # be generated.
You can’t perform that action at this time.
0 commit comments