Safer cover image naming

This commit is contained in:
Mouse Reeve 2021-06-20 09:38:01 -07:00
parent e03b8ef2cd
commit 4a5e4e8ca2

View file

@ -408,7 +408,8 @@ class ImageField(ActivitypubFieldMixin, models.ImageField):
return None return None
image_content = ContentFile(response.content) image_content = ContentFile(response.content)
image_name = str(uuid4()) + "." + imghdr.what(None, image_content.read()) extension = imghdr.what(None, image_content.read()) or ""
image_name = "{:s}.{:s}".format(str(uuid4()), extension)
return [image_name, image_content] return [image_name, image_content]
def formfield(self, **kwargs): def formfield(self, **kwargs):