Remove unneeded startswith in content check of image upload (#98599)

This commit is contained in:
Franck Nijhof 2023-08-18 10:38:21 +02:00 committed by GitHub
parent 89705a22cf
commit 2f204d5747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,8 +78,10 @@ class ImageStorageCollection(collection.DictStorageCollection):
data = self.CREATE_SCHEMA(dict(data)) data = self.CREATE_SCHEMA(dict(data))
uploaded_file: FileField = data["file"] uploaded_file: FileField = data["file"]
if not uploaded_file.content_type.startswith( if uploaded_file.content_type not in (
("image/gif", "image/jpeg", "image/png") "image/gif",
"image/jpeg",
"image/png",
): ):
raise vol.Invalid("Only jpeg, png, and gif images are allowed") raise vol.Invalid("Only jpeg, png, and gif images are allowed")