From 5224f71303b2201f7a744f74241d16d805cba5f1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 12 Feb 2020 10:26:35 +0100 Subject: [PATCH] Correctly check remote extension --- server/lib/activitypub/actor.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index 8c5c618fc..fd934443b 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts @@ -221,9 +221,15 @@ function getAvatarInfoIfExists (actorJSON: ActivityPubActor) { if (!icon || icon.type !== 'Image' || !isActivityPubUrlValid(icon.url)) return undefined - const extension = icon.mediaType - ? mimetypes.MIMETYPE_EXT[icon.mediaType] - : extname(icon.url) + let extension: string + + if (icon.mediaType) { + extension = mimetypes.MIMETYPE_EXT[icon.mediaType] + } else { + const tmp = extname(icon.url) + + if (mimetypes.EXT_MIMETYPE[tmp] !== undefined) extension = tmp + } if (!extension) return undefined -- 2.25.1