From 99f448dd6476dda1ea71037c8af1daa5254c64af Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 30 Dec 2023 19:49:21 +0100 Subject: [PATCH] Strip spaces from uploaded file names (fixes #2415) --- changelog/74_UNRELEASED_xxxx-xx-xx.md | 1 + public/js/extensions.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog/74_UNRELEASED_xxxx-xx-xx.md b/changelog/74_UNRELEASED_xxxx-xx-xx.md index d10f65e8..ad061a60 100644 --- a/changelog/74_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/74_UNRELEASED_xxxx-xx-xx.md @@ -57,6 +57,7 @@ ### General - Optimized sidebar icon spacing (thanks @chris-thorn) +- Fixed that file uploads (product pictures and so on) didn't work for files where the file name contains multiple spaces ### API diff --git a/public/js/extensions.js b/public/js/extensions.js index d9587dce..2c694917 100644 --- a/public/js/extensions.js +++ b/public/js/extensions.js @@ -200,7 +200,12 @@ function QrCodeImgHtml(text) function CleanFileName(fileName) { // Umlaute seem to cause problems on Linux... - return fileName.toLowerCase().replaceAll(/ä/g, 'ae').replaceAll(/ö/g, 'oe').replaceAll(/ü/g, 'ue').replaceAll(/ß/g, 'ss'); + fileName = fileName.toLowerCase().replaceAll(/ä/g, 'ae').replaceAll(/ö/g, 'oe').replaceAll(/ü/g, 'ue').replaceAll(/ß/g, 'ss'); + + // Multiple spaces seem to be a problem, so simply strip them all + fileName = fileName.replace(/\s+/g, ""); + + return fileName; } function nl2br(s)