From: pcanterino <> Date: Tue, 21 Dec 2004 13:40:34 +0000 (+0000) Subject: - While processing a file upload, check if the user wants to replace a directory X-Git-Tag: version_2_3~15 X-Git-Url: https://git.p6c8.net/devedit.git/commitdiff_plain/0705361ceafdfaec2a911e7d34878156bfad1cca?ds=inline - While processing a file upload, check if the user wants to replace a directory or overwrite a write-protected file - If the user wants to copy or rename a file, check if he wants to overwrite a write-protected file --- diff --git a/errors.dat b/errors.dat index 23de6c1..d0ef5c8 100644 --- a/errors.dat +++ b/errors.dat @@ -15,6 +15,7 @@ dir_replace = You are not allowed to replace a directory. edit_failed = Saving of file '{FILE}' failed. The file could be damaged, please check its integrity. editdir = You cannot edit directories. exist_edited = The target file '{FILE}' already exists and is edited by someone else. +exist_no_write = The target file '{FILE}' already exists and you have not enough permissions to replace it. file_exists = A file or directory called '{FILE}' already exists. file_in_use = The file '{FILE}' is currently edited by someone else. file_too_large = The file you want to view or edit is too large (max. {SIZE} Bytes). diff --git a/modules/Command.pm b/modules/Command.pm index 73f9fb4..6c02aa1 100644 --- a/modules/Command.pm +++ b/modules/Command.pm @@ -6,7 +6,7 @@ package Command; # Execute Dev-Editor's commands # # Author: Patrick Canterino -# Last modified: 2004-12-20 +# Last modified: 2004-12-21 # use strict; @@ -493,8 +493,14 @@ sub exec_upload($$) my $file_phys = $physical."/".$filename; my $file_virt = $virtual.$filename; - return error($config->{'errors'}->{'in_use'},$virtual,{FILE => $file_virt}) if($data->{'uselist'}->in_use($file_virt)); - return error($config->{'errors'}->{'file_exists'},$virtual,{FILE => $file_virt}) if(-e $file_phys && not $cgi->param('overwrite')); + return error($config->{'errors'}->{'in_use'},$virtual,{FILE => $file_virt}) if($data->{'uselist'}->in_use($file_virt)); + + if(-e $file_phys) + { + return error($config->{'errors'}->{'dir_replace'},$virtual) if(-d $file_phys); + return error($config->{'errors'}->{'exist_no_write'},$virtual,{FILE => $file_virt}) unless(-w $file_phys); + return error($config->{'errors'}->{'file_exists'},$virtual,{FILE => $file_virt}) unless($cgi->param('overwrite')); + } my $ascii = $cgi->param('ascii'); my $handle = $cgi->upload('uploaded_file'); @@ -551,13 +557,11 @@ sub exec_copy($$) if(-e $new_physical) { - return error($config->{'errors'}->{'exist_edited'},$new_dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'})); + return error($config->{'errors'}->{'exist_edited'},$new_dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'})); + return error($config->{'errors'}->{'dir_replace'},$new_dir) if(-d $new_physical); + return error($config->{'errors'}->{'exist_no_write'},$new_dir,{FILE => $new_virtual}) unless(-w $new_physical); - if(-d $new_physical) - { - return error($config->{'errors'}->{'dir_replace'},$new_dir); - } - elsif(not $data->{'cgi'}->param('confirmed')) + if(not $data->{'cgi'}->param('confirmed')) { my $tpl = new Template; $tpl->read_file($config->{'templates'}->{'confirm_replace'}); @@ -628,13 +632,11 @@ sub exec_rename($$) if(-e $new_physical) { - return error($config->{'errors'}->{'exist_edited'},$new_dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'})); + return error($config->{'errors'}->{'exist_edited'},$new_dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'})); + return error($config->{'errors'}->{'dir_replace'},$new_dir) if(-d $new_physical); + return error($config->{'errors'}->{'exist_no_write'},$new_dir,{FILE => $new_virtual}) unless(-w $new_physical); - if(-d $new_physical) - { - return error($config->{'errors'}->{'dir_replace'},$new_dir); - } - elsif(not $data->{'cgi'}->param('confirmed')) + if(not $data->{'cgi'}->param('confirmed')) { my $tpl = new Template; $tpl->read_file($config->{'templates'}->{'confirm_replace'});