From bb859d588649fdeccad82c2339e698ec89374316 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 30 Jun 2022 14:35:40 +0100 Subject: [PATCH] Fix wrong assertions that all media events have a mimetype (#8946) --- src/components/views/messages/MImageBody.tsx | 2 +- src/utils/Image.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/messages/MImageBody.tsx b/src/components/views/messages/MImageBody.tsx index 45f18f9642..371b88db41 100644 --- a/src/components/views/messages/MImageBody.tsx +++ b/src/components/views/messages/MImageBody.tsx @@ -380,7 +380,7 @@ export default class MImageBody extends React.Component { if (content.info?.w && content.info?.h) { infoWidth = content.info.w; infoHeight = content.info.h; - infoSvg = content.info.mimetype.startsWith("image/svg"); + infoSvg = content.info.mimetype === "image/svg+xml"; } else { // Whilst the image loads, display nothing. We also don't display a blurhash image // because we don't really know what size of image we'll end up with. diff --git a/src/utils/Image.ts b/src/utils/Image.ts index 66d43b1ca4..d4f5ba69eb 100644 --- a/src/utils/Image.ts +++ b/src/utils/Image.ts @@ -16,7 +16,7 @@ import { arrayHasDiff } from "./arrays"; -export function mayBeAnimated(mimeType: string): boolean { +export function mayBeAnimated(mimeType?: string): boolean { // AVIF animation support at the time of writing is only available in Chrome hence not having `blobIsAnimated` check return ["image/gif", "image/webp", "image/png", "image/apng", "image/avif"].includes(mimeType); } @@ -34,7 +34,7 @@ function arrayBufferReadStr(arr: ArrayBuffer, start: number, len: number): strin return String.fromCharCode.apply(null, arrayBufferRead(arr, start, len)); } -export async function blobIsAnimated(mimeType: string, blob: Blob): Promise { +export async function blobIsAnimated(mimeType: string | undefined, blob: Blob): Promise { switch (mimeType) { case "image/webp": { // Only extended file format WEBP images support animation, so grab the expected data range and verify header.