diff --git a/public/js/extensions.js b/public/js/extensions.js index 8b16e2b6..7549919d 100644 --- a/public/js/extensions.js +++ b/public/js/extensions.js @@ -196,3 +196,9 @@ function QrCodeImgHtml(text) return img.outerHTML; } + +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'); +} diff --git a/public/viewjs/components/userfieldsform.js b/public/viewjs/components/userfieldsform.js index 655fbca6..eca3f2d0 100644 --- a/public/viewjs/components/userfieldsform.js +++ b/public/viewjs/components/userfieldsform.js @@ -44,9 +44,9 @@ Grocy.Components.UserfieldsForm.Save = function(success, error) if (input[0].files.length > 0) { // Files service requires an extension - var fileName = RandomString() + '.' + input[0].files[0].name.split('.').reverse()[0]; + var fileName = RandomString() + '.' + CleanFileName(input[0].files[0].name.split('.').reverse()[0]); - jsonData[fieldName] = btoa(fileName) + '_' + btoa(input[0].files[0].name); + jsonData[fieldName] = btoa(fileName) + '_' + btoa(CleanFileName(input[0].files[0].name)); Grocy.Api.UploadFile(input[0].files[0], 'userfiles', fileName, function(result) { diff --git a/public/viewjs/equipmentform.js b/public/viewjs/equipmentform.js index 3cc44439..b42c3e79 100644 --- a/public/viewjs/equipmentform.js +++ b/public/viewjs/equipmentform.js @@ -13,7 +13,7 @@ if ($("#instruction-manual")[0].files.length > 0) { var someRandomStuff = RandomString(); - jsonData.instruction_manual_file_name = someRandomStuff + $("#instruction-manual")[0].files[0].name; + jsonData.instruction_manual_file_name = someRandomStuff + CleanFileName($("#instruction-manual")[0].files[0].name); } if (Grocy.DeleteInstructionManualOnSave) diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index 88a8051e..bc9debb8 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -96,7 +96,7 @@ $('.save-product-button').on('click', function(e) if ($("#product-picture")[0].files.length > 0) { var someRandomStuff = Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100); - jsonData.picture_file_name = someRandomStuff + $("#product-picture")[0].files[0].name; + jsonData.picture_file_name = someRandomStuff + CleanFileName($("#product-picture")[0].files[0].name); } const location = $(e.currentTarget).attr('data-location') == 'return' ? '/products?product=' : '/product/'; diff --git a/public/viewjs/recipeform.js b/public/viewjs/recipeform.js index a9a987c8..6237ee9a 100644 --- a/public/viewjs/recipeform.js +++ b/public/viewjs/recipeform.js @@ -36,7 +36,7 @@ $('.save-recipe').on('click', function(e) if ($("#recipe-picture")[0].files.length > 0) { var someRandomStuff = Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100); - jsonData.picture_file_name = someRandomStuff + $("#recipe-picture")[0].files[0].name; + jsonData.picture_file_name = someRandomStuff + CleanFileName($("#recipe-picture")[0].files[0].name); } const location = $(e.currentTarget).attr('data-location') == 'return' ? '/recipes?recipe=' : '/recipe/'; diff --git a/public/viewjs/userform.js b/public/viewjs/userform.js index e55ffd44..ce348650 100644 --- a/public/viewjs/userform.js +++ b/public/viewjs/userform.js @@ -39,7 +39,7 @@ $('#save-user-button').on('click', function(e) if ($("#user-picture")[0].files.length > 0) { var someRandomStuff = Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100); - jsonData.picture_file_name = someRandomStuff + $("#user-picture")[0].files[0].name; + jsonData.picture_file_name = someRandomStuff + CleanFileName($("#user-picture")[0].files[0].name); } if (Grocy.EditMode === 'create')