Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: replace non-word chars in uploaded filenames (#26022)

Charis69c19889659f
diff --git a/apps/studio/localStores/storageExplorer/StorageExplorerStore.tsx b/apps/studio/localStores/storageExplorer/StorageExplorerStore.tsx
index 1c099791c4e..cf949f3c6b3 100644
--- a/apps/studio/localStores/storageExplorer/StorageExplorerStore.tsx
+++ b/apps/studio/localStores/storageExplorer/StorageExplorerStore.tsx
@@ -561,7 +561,14 @@ class StorageExplorerStore {
const fileName = !isWithinFolder
? this.sanitizeNameForDuplicateInColumn(file.name, autofix)
: file.name
- const formattedFileName = has(file, ['path']) && isWithinFolder ? file.path : fileName
+ const unsanitizedFormattedFileName =
+ has(file, ['path']) && isWithinFolder ? file.path : fileName
+ /**
+ * Storage maintains a list of allowed characters, which excludes
+ * characters such as the narrow no-break space used in Mac screenshots.
+ * To preempt errors, replace all non-word characters with underscores.
+ */
+ const formattedFileName = unsanitizedFormattedFileName.replace(/[^\w.-]/g, '_')
const formattedPathToFile =
pathToFile.length > 0 ? `${pathToFile}/${formattedFileName}` : formattedFileName