fix(pages): normalize Unicode filenames across upload, convert, delete, and download
AL
11h ago+298+298+012345678901234567890123456789-23-23-01234567890123456789
Fixes #697
Summary
Filenames containing German umlauts (or other characters with decomposed NFD vs precomposed NFC forms, e.g. macOS APFS ä U+0061 U+0308 vs ä U+00E4) could fail on Linux byte-exact filesystems with No such file or directory when upload, convert, delete, download, or multi-page output matching used different Unicode normalizations, or when the Debian runtime ran under the default C locale.
Changes
src/helpers/sanitizeFileName.ts: AddedsanitizeFileName(sanitizes and normalizes toNFC) andresolveStoredFileName(fast-pathexistsSyncwith directory fallback matchingentry.normalize("NFC")).src/pages/upload.tsx,src/pages/convert.tsx,src/pages/deleteFile.tsx,src/pages/download.tsx: Switched rawsanitize(...)calls tosanitizeFileName(on upload writes) andresolveStoredFileName(when reading/converting/deleting/downloading stored files).src/converters/main.ts: Normalized filenames when scanning multi-page output files inhandleConvertwhile preserving the actual filename written on disk.Dockerfile: SetENV LANG=C.UTF-8in the Debian runtime image so converters receive a UTF-8 locale.tests/pages/{upload,convert,deleteFile,download}.test.ts: Added regression tests covering NFD upload normalization, cross-normalization (NFC <-> NFD) conversion, deletion, and URL-encoded download.
Verification
Observed locally on Windows (bun 1.4.5):
bun x prettier --check src/helpers/sanitizeFileName.ts src/pages/upload.tsx src/pages/convert.tsx src/pages/deleteFile.tsx src/pages/download.tsx src/converters/main.ts tests/pages/upload.test.ts tests/pages/convert.test.ts tests/pages/deleteFile.test.ts tests/pages/download.test.ts— passedbun run lint:tsc— passed (0type errors across59files)bun run lint:knip— passedbun run lint:xss— passed (No XSS vulnerabilities found in 59 files!)bun x eslint <changed files>— passed (0errors/warnings)bun test tests/helpers/ tests/pages/auth.test.ts tests/pages/chooseConverter.test.ts tests/pages/convert.test.ts tests/pages/deleteFile.test.ts tests/pages/download.test.ts tests/pages/upload.test.ts—86tests passed (214 expect() calls), only the pre-existing Windowstests/preload.ts:47EBUSYcleanup hook failed on teardown (tests/db/db.test.ts:79also hits Windows SQLiteEBUSYon unlink;tests/integrationrequires Docker tools and was not run).
Summary by cubic
Fixes #697 by normalizing Unicode filenames to NFC so names with umlauts (or other decomposed characters) survive upload, convert, delete, and download on Linux byte-exact filesystems.
- New
sanitizeFileNamehelper normalizes NFC before sanitizing;resolveStoredFileNamesresolves exact or NFC-equivalent stored entries in a single async batch. - Upload, convert, delete, and download use these helpers; re-uploading an NFC name replaces an NFD-equivalent stored file; multi-page output matching normalizes filenames too.
- The Docker image sets
LANG=C.UTF-8so converters run in a UTF-8 locale. - Adds regression tests covering NFD uploads, cross-normalization conversion and delete, and URL-encoded downloads.