fix(sync): escape unsafe character in filename (#3109)
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user