From a2a5447e2b3bba47fb0011851bc7a066f4876c39 Mon Sep 17 00:00:00 2001 From: baseplate-admin <61817579+baseplate-admin@users.noreply.github.com> Date: Fri, 22 May 2026 18:30:55 +0600 Subject: [PATCH] feat: ignore binary files --- .../lib/components/FileViewerOverlay.svelte | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/lib/components/FileViewerOverlay.svelte b/src/frontend/src/lib/components/FileViewerOverlay.svelte index f21f5108..f7132b45 100644 --- a/src/frontend/src/lib/components/FileViewerOverlay.svelte +++ b/src/frontend/src/lib/components/FileViewerOverlay.svelte @@ -49,6 +49,32 @@ const baseName = $derived(filename.split(/[/\\]/).pop() ?? filename); + const unopenableExtensions = [ + '.exe', + '.bin', + '.so', + '.dll', + '.msi', + '.app', + '.dmg', + '.pkg', + '.iso', + '.vmdk', + '.a', + '.lib', + '.obj', + '.o', + '.pyc', + '.pyo', + '.pyd', + '.deb', + '.rpm' + ]; + + const isUnopenable = $derived( + unopenableExtensions.some((ext) => filename.toLowerCase().endsWith(ext)) + ); + type MediaKind = 'image' | 'video' | 'audio' | 'other'; type ImageInfo = { @@ -182,7 +208,7 @@ imageSupport = null; resetHeicState(); - if (!contentUrl || contentText !== null) return; + if (!contentUrl || contentText !== null || isUnopenable) return; let cancelled = false; @@ -255,7 +281,7 @@ const toolbarActions = $derived([ { key: 'copy-text', - isVisible: contentText !== null, + isVisible: contentText !== null && !isUnopenable, label: 'Copy Text', activeLabel: 'Copied Text', icon: Copy, @@ -357,7 +383,16 @@
- {#if contentText !== null} + {#if isUnopenable} +
+
+

This file type cannot be previewed.

+

+ Binary files and executables are not supported for online viewing. +

+
+
+ {:else if contentText !== null}