From f9d84f59073ba1416b73b4af35d7876665c7dd1f Mon Sep 17 00:00:00 2001 From: jubnl Date: Sun, 16 Aug 2026 09:53:25 +0200 Subject: [PATCH] fix(storage): default defParamCharset to utf8 in the upload factory --- server/src/nest/storage/storage-upload.factory.ts | 6 ++++-- .../tests/unit/nest/storage/storage-upload.factory.test.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/src/nest/storage/storage-upload.factory.ts b/server/src/nest/storage/storage-upload.factory.ts index 4ada1b867..efbd16776 100644 --- a/server/src/nest/storage/storage-upload.factory.ts +++ b/server/src/nest/storage/storage-upload.factory.ts @@ -36,7 +36,7 @@ export interface StorageUploadOptions { * the pre-factory call sites). */ filename?: (req: Request, file: Express.Multer.File) => string; - /** Parity-phase opt-in (files + collab pass 'utf8'). */ + /** Always 'utf8' since fix #3; the option remains for explicit callers. */ defParamCharset?: 'utf8'; } @@ -63,6 +63,8 @@ export function buildStorageUploadOptions(storage: StorageService, opts: Storage }), limits: { fileSize: opts.maxSize }, ...(opts.fileFilter ? { fileFilter: opts.fileFilter } : {}), - ...(opts.defParamCharset ? { defParamCharset: opts.defParamCharset } : {}), + // Uniform since fix #3: non-ASCII original filenames decode as UTF-8 on + // every upload route (previously only trip files + collab opted in). + defParamCharset: opts.defParamCharset ?? 'utf8', }; } diff --git a/server/tests/unit/nest/storage/storage-upload.factory.test.ts b/server/tests/unit/nest/storage/storage-upload.factory.test.ts index 29e5fbf55..df08c84eb 100644 --- a/server/tests/unit/nest/storage/storage-upload.factory.test.ts +++ b/server/tests/unit/nest/storage/storage-upload.factory.test.ts @@ -151,10 +151,10 @@ describe('buildStorageUploadOptions', () => { expect('fileFilter' in without).toBe(false); }); - it('STORAGE-UPLOAD-010 — defParamCharset is absent unless passed, utf8 when passed', () => { + it('STORAGE-UPLOAD-010 — defParamCharset defaults to utf8 everywhere (fix #3)', () => { const storage = { spoolDirFor: () => dirA } as unknown as StorageService; const without = buildStorageUploadOptions(storage, { category: 'files', maxSize: 10 }); - expect('defParamCharset' in without).toBe(false); + expect((without as { defParamCharset?: string }).defParamCharset).toBe('utf8'); const withCharset = buildStorageUploadOptions(storage, { category: 'files', maxSize: 10, defParamCharset: 'utf8' }); expect((withCharset as { defParamCharset?: string }).defParamCharset).toBe('utf8');