Strip spaces from uploaded file names (fixes #2415)

This commit is contained in:
Bernd Bestel 2023-12-30 19:49:21 +01:00
parent 7f7f1e8dce
commit 99f448dd64
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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)