From 0a1f4b793172dd29bc83256a72198ec1995ac885 Mon Sep 17 00:00:00 2001 From: atm-josselin Date: Tue, 23 Jul 2019 09:45:17 +0200 Subject: [PATCH] FIX : correct error in files with multiple spaces --- htdocs/core/lib/files.lib.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index fa1a5e50a50..ed169573117 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1540,6 +1540,11 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio $info = pathinfo($destfile); $destfile = dol_sanitizeFileName($info['filename'].'.'.strtolower($info['extension'])); + // We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because + // this function is also applied when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). + $destfile = dol_string_nohtmltag($destfile); + $destfull = dol_string_nohtmltag($destfull); + $resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles); if (is_numeric($resupload) && $resupload > 0) // $resupload can be 'ErrorFileAlreadyExists'