diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index f2da1f3cc8e..b3b14c39593 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -862,13 +862,15 @@ class Translate /** * Convert a string into output charset (this->charset_output that should be defined to conf->file->character_set_client) * - * @param string $str String to convert - * @param string $pagecodefrom Page code of src string - * @param string $pagecodeto Expected page code of returned string - * @return string Converted string + * @param string|null $str String to convert + * @param string $pagecodefrom Page code of src string + * @param string $pagecodeto Expected page code of returned string + * @return string Converted string */ public function convToOutputCharset($str, $pagecodefrom = 'UTF-8', $pagecodeto = '') { + $str = (string) $str; + if (empty($pagecodeto)) { $pagecodeto = $this->charset_output; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ea1c96fb8d8..22162b87424 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1915,16 +1915,18 @@ 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 (Note: ' - ' is allowed). * - * @param string $str String to clean - * @param string $newstr String to replace bad chars with. - * @param int $unaccent 1=Remove also accent (default), 0 do not remove them - * @param int $includequotes 1=Include simple quotes (double is already included by default) - * @return string String cleaned + * @param string|null $str String to clean + * @param string $newstr String to replace bad chars with. + * @param int $unaccent 1=Remove also accent (default), 0 do not remove them + * @param int $includequotes 1=Include simple quotes (double is already included by default) + * @return string String cleaned * * @see dol_string_nospecial(), dol_string_unaccent(), dol_sanitizePathName() */ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1, $includequotes = 0) { + $str = (string) $str; + // List of special chars for filenames in windows are defined on page https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file // Char '>' '<' '|' '$' and ';' are special chars for shells. // Char '/' and '\' are file delimiters.