From 50b1bc2b246c71f7951d5723a0a3002f9f3076c0 Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Mon, 9 Jun 2025 23:11:53 +0100 Subject: [PATCH] sanitize file names --- src/components/Controlbar.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Controlbar.tsx b/src/components/Controlbar.tsx index 1e7911d..0f84a06 100644 --- a/src/components/Controlbar.tsx +++ b/src/components/Controlbar.tsx @@ -25,7 +25,11 @@ export default component$(() => { } try { - await api.upload(uploadingFile.value as File) + const unsafe = uploadingFile.value as File; + const name = unsafe.name.replace(/[^a-zA-Z0-9_.-]/g, "_"); + const f = new File([unsafe], name, { type: unsafe.type }); + + await api.upload(f); files.value = await api.list(); } catch (error) { console.error("Error uploading file:", error);