import ExternalSVG from '../../../../public/res/ic/outlined/external.svg';
import PlaySVG from '../../../../public/res/ic/outlined/play.svg';
-// https://github.com/matrix-org/matrix-react-sdk/blob/cd15e08fc285da42134817cce50de8011809cd53/src/utils/blobs.ts#L73
-const ALLOWED_BLOB_MIMETYPES = [
- 'image/jpeg',
- 'image/gif',
- 'image/png',
- 'image/apng',
- 'image/webp',
- 'image/avif',
-
- 'video/mp4',
- 'video/webm',
- 'video/ogg',
- 'video/quicktime',
-
- 'audio/mp4',
- 'audio/webm',
- 'audio/aac',
- 'audio/mpeg',
- 'audio/ogg',
- 'audio/wave',
- 'audio/wav',
- 'audio/x-wav',
- 'audio/x-pn-wav',
- 'audio/flac',
- 'audio/x-flac',
-];
-function getBlobSafeMimeType(mimetype) {
- if (!ALLOWED_BLOB_MIMETYPES.includes(mimetype)) {
- return 'application/octet-stream';
- }
- // Required for Chromium browsers
- if (mimetype === 'video/quicktime') {
- return 'video/mp4';
- }
- return mimetype;
-}
+import { getBlobSafeMimeType } from '../../../util/mimetypes';
async function getDecryptedBlob(response, type, decryptData) {
const arrayBuffer = await response.arrayBuffer();
import BinIC from '../../../../public/res/ic/outlined/bin.svg';
import { confirmDialog } from '../confirm-dialog/ConfirmDialog';
+import { getBlobSafeMimeType } from '../../../util/mimetypes';
function PlaceholderMessage() {
return (
if (typeof mediaMXC === 'undefined' || mediaMXC === '') return <span style={{ color: 'var(--bg-danger)' }}>Malformed event</span>;
let msgType = mE.getContent()?.msgtype;
- if (mE.getType() === 'm.sticker') msgType = 'm.sticker';
+ const safeMimetype = getBlobSafeMimeType(mContent.info?.mimetype);
+ if (mE.getType() === 'm.sticker') {
+ msgType = 'm.sticker';
+ } else if (safeMimetype === 'application/octet-stream') {
+ msgType = 'm.file';
+ }
const blurhash = mContent?.info?.['xyz.amorgan.blurhash'];
import { encode } from 'blurhash';
import { getShortcodeToEmoji } from '../../app/organisms/emoji-board/custom-emoji';
import { mathExtensionHtml, spoilerExtension, spoilerExtensionHtml } from '../../util/markdown';
+import { getBlobSafeMimeType } from '../../util/mimetypes';
import { sanitizeText } from '../../util/sanitize';
import cons from './cons';
import settings from './settings';
}
async sendFile(roomId, file) {
- const fileType = file.type.slice(0, file.type.indexOf('/'));
+ const fileType = getBlobSafeMimeType(file.type).slice(0, file.type.indexOf('/'));
const info = {
mimetype: file.type,
size: file.size,
--- /dev/null
+// https://github.com/matrix-org/matrix-react-sdk/blob/cd15e08fc285da42134817cce50de8011809cd53/src/utils/blobs.ts
+export const ALLOWED_BLOB_MIMETYPES = [
+ 'image/jpeg',
+ 'image/gif',
+ 'image/png',
+ 'image/apng',
+ 'image/webp',
+ 'image/avif',
+
+ 'video/mp4',
+ 'video/webm',
+ 'video/ogg',
+ 'video/quicktime',
+
+ 'audio/mp4',
+ 'audio/webm',
+ 'audio/aac',
+ 'audio/mpeg',
+ 'audio/ogg',
+ 'audio/wave',
+ 'audio/wav',
+ 'audio/x-wav',
+ 'audio/x-pn-wav',
+ 'audio/flac',
+ 'audio/x-flac',
+];
+
+export function getBlobSafeMimeType(mimetype) {
+ if (!ALLOWED_BLOB_MIMETYPES.includes(mimetype)) {
+ return 'application/octet-stream';
+ }
+ // Required for Chromium browsers
+ if (mimetype === 'video/quicktime') {
+ return 'video/mp4';
+ }
+ return mimetype;
+}