diff --git a/apps/readest-app/src/__tests__/utils/misc.test.ts b/apps/readest-app/src/__tests__/utils/misc.test.ts index d2f16124..f6e92c15 100644 --- a/apps/readest-app/src/__tests__/utils/misc.test.ts +++ b/apps/readest-app/src/__tests__/utils/misc.test.ts @@ -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', () => { diff --git a/apps/readest-app/src/utils/misc.ts b/apps/readest-app/src/utils/misc.ts index c4de55d6..3f44772e 100644 --- a/apps/readest-app/src/utils/misc.ts +++ b/apps/readest-app/src/utils/misc.ts @@ -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;