FIX: Clean filenames with double spaces (#37256)

* Clean filenames with double spaces

If a filename contains double spaces, it can get uploaded in Dolibarr exactly as it is.

When listing the file or trying to download it, the dolibarr functions clear double spaces in the filename. In particular the alpha parameter for GETPOST.

This results in files being uploaded (e.g. attachments for invoices) than can get listed but remain inaccessible and even cannot get deleted via UI. 

We either need to fix all these places to accept double spaces or we change a single location, when we sanitize filenames.

* removed white space
This commit is contained in:
Joachim Kueter 2026-02-16 20:03:22 +01:00 committed by GitHub
parent 83b137d854
commit 7a37ebbeb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1783,6 +1783,7 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1, $includequotes
$tmp = preg_replace('/\s+\-([^\s])/', ' _$1', $tmp);
$tmp = preg_replace('/\s+\-$/', '', $tmp);
$tmp = str_replace('..', '', $tmp);
$tmp = preg_replace('/\s{2,}/', ' ', $tmp);
return $tmp;
}
@ -1815,6 +1816,8 @@ function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1)
$tmp = preg_replace('/\s+\-([^\s])/', ' _$1', $tmp);
$tmp = preg_replace('/\s+\-$/', '', $tmp);
$tmp = str_replace('..', '', $tmp);
$tmp = preg_replace('/\s{2,}/', ' ', $tmp);
return $tmp;
}