mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 17:48:25 +01:00
FIX Deletion of files in migration
This commit is contained in:
@@ -1118,10 +1118,11 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
|
|||||||
* @param int $nophperrors Disable all PHP output errors
|
* @param int $nophperrors Disable all PHP output errors
|
||||||
* @param int $nohook Disable all hooks
|
* @param int $nohook Disable all hooks
|
||||||
* @param object $object Current object in use
|
* @param object $object Current object in use
|
||||||
|
* @param boolean $allowdotdot Allow to delete file path with .. inside. Never use this, it is reserved for migration purpose.
|
||||||
* @return boolean True if no error (file is deleted or if glob is used and there's nothing to delete), False if error
|
* @return boolean True if no error (file is deleted or if glob is used and there's nothing to delete), False if error
|
||||||
* @see dol_delete_dir
|
* @see dol_delete_dir
|
||||||
*/
|
*/
|
||||||
function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=null)
|
function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=null,$allowdotdot=false)
|
||||||
{
|
{
|
||||||
global $db, $conf, $user, $langs;
|
global $db, $conf, $user, $langs;
|
||||||
global $hookmanager;
|
global $hookmanager;
|
||||||
@@ -1133,7 +1134,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
|
|||||||
|
|
||||||
// Security:
|
// Security:
|
||||||
// We refuse transversal using .. and pipes into filenames.
|
// We refuse transversal using .. and pipes into filenames.
|
||||||
if (preg_match('/\.\./',$file) || preg_match('/[<>|]/',$file))
|
if ((! $allowdotdot && preg_match('/\.\./',$file)) || preg_match('/[<>|]/',$file))
|
||||||
{
|
{
|
||||||
dol_syslog("Refused to delete file ".$file, LOG_WARNING);
|
dol_syslog("Refused to delete file ".$file, LOG_WARNING);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -4442,7 +4442,7 @@ function migrate_delete_old_files($db,$langs,$conf)
|
|||||||
$result=1;
|
$result=1;
|
||||||
if (file_exists($filetodelete))
|
if (file_exists($filetodelete))
|
||||||
{
|
{
|
||||||
$result=dol_delete_file($filetodelete);
|
$result=dol_delete_file($filetodelete,0,0,0,null,true);
|
||||||
if (! $result)
|
if (! $result)
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
|
|||||||
Reference in New Issue
Block a user