Correctly check remote extension
authorChocobozzz <me@florianbigard.com>
Wed, 12 Feb 2020 09:26:35 +0000 (10:26 +0100)
committerChocobozzz <me@florianbigard.com>
Wed, 12 Feb 2020 09:26:35 +0000 (10:26 +0100)
server/lib/activitypub/actor.ts

index 8c5c618fc2e8ff80125fb9e5492eac220f0c7d91..fd934443b8dd19725db0c495dd509443da6c5b25 100644 (file)
@@ -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