fix(sync): escape unsafe character in filename (#3109)

This commit is contained in:
Huang Xin
2026-01-29 15:13:02 +01:00
committed by GitHub
parent bdb25999c9
commit c8c761b017
2 changed files with 2 additions and 2 deletions
@@ -193,7 +193,7 @@ describe('makeSafeFilename', () => {
});
it('should handle string with only unsafe characters', () => {
expect(makeSafeFilename('<>:"|?*')).toBe('_______');
expect(makeSafeFilename('<>:"|?*#')).toBe('________');
});
it('should handle string that becomes empty after sanitization and trimming', () => {
+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;