diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0dc5a2c4456..8590f63803f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -597,7 +597,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable global $conf, $db, $user, $langs; global $object, $hookmanager; - $error=0; + $reshook=0; $file_name = $dest_file; if (empty($nohook)) @@ -663,8 +663,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable } // Security: - // On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans - // les noms de fichiers. + // On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans les noms de fichiers. if (preg_match('/^\./',$dest_file) || preg_match('/\.\./',$dest_file) || preg_match('/[<>|]/',$dest_file)) { dol_syslog("Refused to deliver file ".$dest_file, LOG_WARNING); @@ -677,7 +676,13 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable $reshook=$hookmanager->executeHooks('moveUploadedFile', $parameters, $object); } - if (empty($reshook)) + if ($reshook < 0) // At least one blocking error returned by one hook + { + $errmsg = join(',', $hookmanager->errors); + if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks'; // Should not occurs. Added if hook is bugged and does not set ->errors when there is error. + return $errmsg; + } + elseif (empty($reshook)) { // The file functions must be in OS filesystem encoding. $src_file_osencoded=dol_osencode($src_file); @@ -710,8 +715,8 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable return -3; // Unknown error } } - else - return $reshook; + + return 1; // Success } /** @@ -802,12 +807,12 @@ function dol_delete_dir($dir,$nophperrors=0) } /** - * Remove a directory $dir and its subdirectories (or only files and subdirectories) + * Remove a directory $dir and its subdirectories (or only files and subdirectories) * * @param string $dir Dir to delete * @param int $count Counter to count nb of deleted elements * @param int $nophperrors Disable all PHP output errors - * @param int $onlysub Delete only files and subdir, not main directory + * @param int $onlysub Delete only files and subdir, not main directory * @return int Number of files and directory removed */ function dol_delete_dir_recursive($dir,$count=0,$nophperrors=0,$onlysub=0) @@ -837,7 +842,7 @@ function dol_delete_dir_recursive($dir,$count=0,$nophperrors=0,$onlysub=0) } } closedir($handle); - + if (empty($onlysub)) { dol_delete_dir($dir,$nophperrors);