From e31b4973197f7d0ca6b9ca5fbf2ba923d3ea63fe Mon Sep 17 00:00:00 2001 From: pcanterino <> Date: Thu, 16 Dec 2004 15:45:32 +0000 Subject: [PATCH 1/1] - Entities in some more strings are now encoded - The Hash Reference for devedit_reload() is now optional - Removed "use Data::Dumper;" in Command.pm. I forgot to remove it after debugging. --- modules/Command.pm | 26 ++++++++++++-------------- modules/Tool.pm | 24 +++++++++++++++--------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/modules/Command.pm b/modules/Command.pm index 0915697..24e9a69 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-13 +# Last modified: 2004-12-16 # use strict; @@ -25,9 +25,7 @@ use HTML::Entities; use Output; use Template; -use Data::Dumper; - -my $script = $ENV{'SCRIPT_NAME'}; +my $script = encode_entities($ENV{'SCRIPT_NAME'}); my $users = eval("getpwuid(0)") && eval("getgrgid(0)"); my %dispatch = ('show' => \&exec_show, @@ -91,7 +89,7 @@ sub exec_show($$) my ($data,$config) = @_; my $physical = $data->{'physical'}; my $virtual = $data->{'virtual'}; - my $upper_path = upper_path($virtual); + my $upper_path = encode_entities(upper_path($virtual)); my $uselist = $data->{'uselist'}; my $tpl = new Template; @@ -103,7 +101,7 @@ sub exec_show($$) return error($config->{'errors'}->{'no_dir_access'},$upper_path) unless(-r $physical && -x $physical); my $direntries = dir_read($physical); - return error($config->{'dir_read_fail'},$upper_path,{DIR => $virtual}) unless($direntries); + return error($config->{'dir_read_fail'},$upper_path,{DIR => encode_entities($virtual)}) unless($direntries); my $files = $direntries->{'files'}; my $dirs = $direntries->{'dirs'}; @@ -122,7 +120,7 @@ sub exec_show($$) my $udtpl = new Template; $udtpl->read_file($config->{'templates'}->{'dirlist_up'}); - $udtpl->fillin("UPPER_DIR",encode_entities($upper_path)); + $udtpl->fillin("UPPER_DIR",$upper_path); $udtpl->fillin("DATE",encode_entities(strftime($config->{'timeformat'},localtime($stat[9])))); $dirlist .= $udtpl->get_template; @@ -141,7 +139,7 @@ sub exec_show($$) $dtpl->read_file($config->{'templates'}->{'dirlist_dir'}); $dtpl->fillin("DIR",$virt_path); - $dtpl->fillin("DIR_NAME",$dir); + $dtpl->fillin("DIR_NAME",encode_entities($dir)); $dtpl->fillin("DATE",encode_entities(strftime($config->{'timeformat'},localtime($stat[9])))); $dtpl->fillin("URL",equal_url($config->{'httproot'},$virt_path)); @@ -166,7 +164,7 @@ sub exec_show($$) $ftpl->read_file($config->{'templates'}->{'dirlist_file'}); $ftpl->fillin("FILE",$virt_path); - $ftpl->fillin("FILE_NAME",$file); + $ftpl->fillin("FILE_NAME",encode_entities($file)); $ftpl->fillin("SIZE",$stat[7]); $ftpl->fillin("DATE",encode_entities(strftime($config->{'timeformat'},localtime($stat[9])))); $ftpl->fillin("URL",equal_url($config->{'httproot'},$virt_path)); @@ -191,7 +189,7 @@ sub exec_show($$) $tpl->read_file($config->{'templates'}->{'dirlist'}); $tpl->fillin("DIRLIST",$dirlist); - $tpl->fillin("DIR",$virtual); + $tpl->fillin("DIR",encode_entities($virtual)); $tpl->fillin("SCRIPT",$script); $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual)); @@ -228,7 +226,7 @@ sub exec_show($$) $tpl->read_file($config->{'templates'}->{'viewfile'}); - $tpl->fillin("FILE",$virtual); + $tpl->fillin("FILE",encode_entities($virtual)); $tpl->fillin("DIR",$upper_path); $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual)); $tpl->fillin("SCRIPT",$script); @@ -916,13 +914,13 @@ sub exec_about($$) # Perl $tpl->fillin("PERL_PROG",encode_entities($^X)); - $tpl->fillin("PERL_VER",sprintf("%vd",$^V)); + $tpl->fillin("PERL_VER", sprintf("%vd",$^V)); # Information about the server $tpl->fillin("HTTPD",encode_entities($ENV{'SERVER_SOFTWARE'})); - $tpl->fillin("OS",$^O); - $tpl->fillin("TIME",encode_entities(strftime($config->{'timeformat'},localtime))); + $tpl->fillin("OS", encode_entities($^O)); + $tpl->fillin("TIME", encode_entities(strftime($config->{'timeformat'},localtime))); # Process information diff --git a/modules/Tool.pm b/modules/Tool.pm index baaff16..6a615da 100644 --- a/modules/Tool.pm +++ b/modules/Tool.pm @@ -6,7 +6,7 @@ package Tool; # Some shared sub routines # # Author: Patrick Canterino -# Last modified: 2004-11-13 +# Last modified: 2004-12-16 # use strict; @@ -106,10 +106,11 @@ sub clean_path($) # with some other parameters # # Params: Hash Reference (will be merged to a query string) +# (optional) # # Return: HTTP redirection header (Scalar Reference) -sub devedit_reload($) +sub devedit_reload(;$) { my $params = shift; @@ -138,13 +139,18 @@ sub devedit_reload($) # Andre Malo's selfforum (http://sourceforge.net/projects/selfforum/) # and modified by Patrick Canterino - my $query = '?'.join ('&' => - map { - (ref) - ? map{escape ($_).'='.escape ($params -> {$_})} @{$params -> {$_}} - : escape ($_).'='.escape ($params -> {$_}) - } keys %$params - ); + my $query = ""; + + if(ref($params) eq "HASH") + { + $query = '?'.join ('&' => + map { + (ref) + ? map{escape ($_).'='.escape ($params -> {$_})} @{$params -> {$_}} + : escape ($_).'='.escape ($params -> {$_}) + } keys %$params + ); + } # Create the redirection header -- 2.34.1