mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Allow non-ASCII characters in file names of uploaded files (closes #2484)
This commit is contained in:
parent
5a2600209f
commit
c21090f522
@ -59,4 +59,4 @@
|
|||||||
|
|
||||||
### API
|
### API
|
||||||
|
|
||||||
- xxx
|
- Optimized that uploading files where the file name contains non-ASCII characters is now also possible
|
||||||
|
@ -205,6 +205,9 @@ function CleanFileName(fileName)
|
|||||||
// Multiple spaces seem to be a problem, so simply strip them all
|
// Multiple spaces seem to be a problem, so simply strip them all
|
||||||
fileName = fileName.replace(/\s+/g, "");
|
fileName = fileName.replace(/\s+/g, "");
|
||||||
|
|
||||||
|
// Remove any non-ASCII character
|
||||||
|
fileName = fileName.replace(/[^\x00-\x7F]/g, "");
|
||||||
|
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
|
|
||||||
if ($("#instruction-manual")[0].files.length > 0)
|
if ($("#instruction-manual")[0].files.length > 0)
|
||||||
{
|
{
|
||||||
var someRandomStuff = RandomString();
|
jsonData.instruction_manual_file_name = RandomString() + CleanFileName($("#instruction-manual")[0].files[0].name);
|
||||||
jsonData.instruction_manual_file_name = someRandomStuff + CleanFileName($("#instruction-manual")[0].files[0].name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Grocy.DeleteInstructionManualOnSave)
|
if (Grocy.DeleteInstructionManualOnSave)
|
||||||
|
@ -95,8 +95,7 @@ $('.save-product-button').on('click', function(e)
|
|||||||
|
|
||||||
if ($("#product-picture")[0].files.length > 0)
|
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 = RandomString() + CleanFileName($("#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/';
|
const location = $(e.currentTarget).attr('data-location') == 'return' ? '/products?product=' : '/product/';
|
||||||
|
@ -40,8 +40,7 @@ $('.save-recipe').on('click', function(e)
|
|||||||
|
|
||||||
if ($("#recipe-picture")[0].files.length > 0)
|
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 = RandomString() + CleanFileName($("#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/';
|
const location = $(e.currentTarget).attr('data-location') == 'return' ? '/recipes?recipe=' : '/recipe/';
|
||||||
|
@ -43,8 +43,7 @@ $('#save-user-button').on('click', function(e)
|
|||||||
|
|
||||||
if ($("#user-picture")[0].files.length > 0)
|
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 = RandomString() + CleanFileName($("#user-picture")[0].files[0].name);
|
||||||
jsonData.picture_file_name = someRandomStuff + CleanFileName($("#user-picture")[0].files[0].name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Grocy.EditMode === 'create')
|
if (Grocy.EditMode === 'create')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user