2
0
forked from Wavyzz/dolibarr

Fix allow ' - ' into file name

This commit is contained in:
Laurent Destailleur
2021-10-17 12:21:22 +02:00
parent 8bdece7101
commit b30d7371a4

View File

@@ -1055,7 +1055,7 @@ function dol_size($size, $type = '')
/**
* Clean a string to use it as a file name.
* Replace also '--' and ' -' strings, they are used for parameters separation.
* Replace also '--' and ' -' strings, they are used for parameters separation (Note: ' - ' is allowed).
*
* @param string $str String to clean
* @param string $newstr String to replace bad chars with.
@@ -1073,13 +1073,13 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1)
$filesystem_forbidden_chars = array('<', '>', '/', '\\', '?', '*', '|', '"', ':', '°', '$', ';');
$tmp = dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars);
$tmp = preg_replace('/\-\-+/', '_', $tmp);
$tmp = preg_replace('/\s+\-/', ' _', $tmp);
$tmp = preg_replace('/\s+\-([^\s])/', ' _$1', $tmp);
return $tmp;
}
/**
* Clean a string to use it as a path name.
* Replace also '--' and ' -' strings, they are used for parameters separation.
* Replace also '--' and ' -' strings, they are used for parameters separation (Note: ' - ' is allowed).
*
* @param string $str String to clean
* @param string $newstr String to replace bad chars with
@@ -1093,7 +1093,7 @@ function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1)
$filesystem_forbidden_chars = array('<', '>', '?', '*', '|', '"', '°');
$tmp = dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars);
$tmp = preg_replace('/\-\-+/', '_', $tmp);
$tmp = preg_replace('/\s+\-/', ' _', $tmp);
$tmp = preg_replace('/\s+\-([^\s])/', ' _$1', $tmp);
return $tmp;
}