From 76a0076b6530a3a2d5ec8e38cba8be03edb61372 Mon Sep 17 00:00:00 2001 From: ScreenTinker Date: Tue, 28 Apr 2026 10:13:41 -0500 Subject: [PATCH] Fix UTF-8 encoding for special characters in filenames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit multer/busboy decode multipart filename headers as latin1 by default, which mangled umlauts and other non-ASCII characters end-to-end (Größe.jpg arrived as Größe.jpg and was stored that way). Setting defParamCharset: 'utf8' on the multer options makes the entire upload pipeline consistent UTF-8. Co-Authored-By: Claude Opus 4.7 (1M context) --- server/middleware/upload.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/middleware/upload.js b/server/middleware/upload.js index f744ad6..ed9f0c7 100644 --- a/server/middleware/upload.js +++ b/server/middleware/upload.js @@ -26,10 +26,14 @@ const fileFilter = (req, file, cb) => { } }; +// `defParamCharset: 'utf8'` makes busboy decode multipart filename headers as UTF-8. +// Default is latin1, which mangles umlauts and other non-ASCII characters +// (e.g. "Größe.jpg" arrives as "Größe.jpg" and gets stored that way). const upload = multer({ storage, fileFilter, - limits: { fileSize: config.maxFileSize } + limits: { fileSize: config.maxFileSize }, + defParamCharset: 'utf8' }); module.exports = upload;