sanitize file names

This commit is contained in:
grngxd 2025-06-09 23:11:53 +01:00
parent c1726f5a39
commit 50b1bc2b24

View file

@ -25,7 +25,11 @@ export default component$(() => {
} }
try { 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(); files.value = await api.list();
} catch (error) { } catch (error) {
console.error("Error uploading file:", error); console.error("Error uploading file:", error);