From 884248987ec0024c998ba725cfc7d4e497bf8a41 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Sun, 17 Mar 2024 02:32:17 +1300 Subject: [PATCH] make_image_sizes_async: fall back to parsing the http content type if the url does not contain a file extension --- app/activitypub/util.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 9832d476..0056cc0e 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -693,6 +693,11 @@ def make_image_sizes_async(file_id, thumbnail_width, medium_width, directory): source_image_response.close() file_ext = os.path.splitext(file.source_url)[1] + # fall back to parsing the http content type if the url does not contain a file extension + if file_ext == '': + content_type_parts = content_type.split('/') + if content_type_parts: + file_ext = '.' + content_type_parts[-1] new_filename = gibberish(15)