mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-24 00:50:35 +00:00
Safer cover image naming
This commit is contained in:
parent
e03b8ef2cd
commit
4a5e4e8ca2
1 changed files with 2 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue