fix(upload): sanitize filenames before uploading to cloud bucket (#2396)

This commit is contained in:
Huang Xin
2025-11-03 18:17:24 +08:00
committed by GitHub
parent f79d84b5fa
commit ec7145bb01
+1 -1
View File
@@ -9,7 +9,7 @@ export const getContentMd5 = (content: unknown) => md5(JSON.stringify(content));
export const makeSafeFilename = (filename: string, replacement = '_') => {
// Windows restricted characters + control characters and reserved names
const unsafeCharacters = /[<>:"\/\\|?*\x00-\x1F]/g;
const unsafeCharacters = /[<>:%"\/\\|?*\x00-\x1F]/g;
const reservedFilenames = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i;
// Unsafe to use filename including file extensions over 255 bytes on Android
const maxFilenameBytes = 250;