Merge pull request #1193 from bookwyrm-social/cover-images

Safer cover image naming
This commit is contained in:
Mouse Reeve 2021-06-20 12:08:35 -07:00 committed by GitHub
commit 2f279bbbd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -408,7 +408,8 @@ class ImageField(ActivitypubFieldMixin, models.ImageField):
return None
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]
def formfield(self, **kwargs):