From 73f2498331782691215bb4cc02fc4431145b7027 Mon Sep 17 00:00:00 2001 From: pcanterino <> Date: Sat, 13 Nov 2004 08:56:34 +0000 Subject: [PATCH] - The abort() routine from the Output module is now also able to display a link at the bottom of the error message. It is a direct wrapper to the error() routine. Thus, the following error messages now contain a link at the bottom: - File not found - Accessing above the virtual root directory - Creating an object above the virtual root directory - Directory where Dev-Editor should create an object does not exist - It was possible to access the directory containing the virtual root directory. Well, it was only read-access. --- devedit.pl | 12 ++++++------ modules/Output.pm | 11 ++++++----- modules/Tool.pm | 6 ++++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/devedit.pl b/devedit.pl index eccebd0..aa7a3ca 100644 --- a/devedit.pl +++ b/devedit.pl @@ -6,7 +6,7 @@ # Dev-Editor's main program # # Author: Patrick Canterino -# Last modified: 2004-11-07 +# Last modified: 2004-11-13 # use strict; @@ -72,14 +72,14 @@ if($newfile ne '' && $newfile !~ /^\s+$/) unless(-d clean_path($config->{'fileroot'}."/".$dir)) { - abort($config->{'errors'}->{'dir_not_exist'}); + abort($config->{'errors'}->{'dir_not_exist'},"/"); } # ... and check if the path is above the root directory unless(($new_physical,$new_virtual) = check_path($config->{'fileroot'},$dir)) { - abort($config->{'errors'}->{'create_ar'}); + abort($config->{'errors'}->{'create_ar'},"/"); } # Create the physical and the virtual path @@ -100,7 +100,7 @@ if(-e clean_path($config->{'fileroot'}."/".$file)) lockfile => $config->{'lock_file'}, timeout => $config->{'lock_timeout'}); - $uselist->lock or abort($config->{'errors'}->{'lock_failed'},{USELIST => $config->{'uselist_file'}, LOCK_FILE => $config->{'lock_file'}}); + $uselist->lock or abort($config->{'errors'}->{'lock_failed'},undef,{USELIST => $config->{'uselist_file'}, LOCK_FILE => $config->{'lock_file'}}); $uselist->load; # Create a hash with data submitted by user @@ -122,12 +122,12 @@ if(-e clean_path($config->{'fileroot'}."/".$file)) } else { - abort($config->{'errors'}->{'above_root'}); + abort($config->{'errors'}->{'above_root'},"/"); } } else { - abort($config->{'errors'}->{'not_exist'}); + abort($config->{'errors'}->{'not_exist'},"/"); } # diff --git a/modules/Output.pm b/modules/Output.pm index eff7459..5fd22bf 100644 --- a/modules/Output.pm +++ b/modules/Output.pm @@ -6,7 +6,7 @@ package Output; # HTML generating routines # # Author: Patrick Canterino -# Last modified: 2004-03-12 +# Last modified: 2004-11-13 # use strict; @@ -46,7 +46,7 @@ sub error_template($) # Format an error message # # Params: 1. Error message -# 2. Virtual path to which a link should be displayed (optional) +# 2. Display a link to this path at the bottom of the page (optional) # 3. Hash reference: Template variables (optional) # # Return: Formatted message (Scalar Reference) @@ -84,11 +84,12 @@ sub error($;$$) # ^^^^^ # # Params: 1. Error message -# 2. Hash reference: Template variables (optional) +# 2. Display a link to this path at the bottom of the page (optional) +# 3. Hash reference: Template variables (optional) -sub abort($;$) +sub abort($;$$) { - my $output = error(shift,undef,shift); + my $output = error(shift,shift,shift); print $$output; exit; } diff --git a/modules/Tool.pm b/modules/Tool.pm index 8d578ef..2d044e0 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-04 +# Last modified: 2004-11-13 # use strict; @@ -64,11 +64,13 @@ sub check_path($$) $first = abs_path($first); $path = $first."/".$last; - $path = File::Spec->canonpath($path); + $first = File::Spec->canonpath($first); + $path = File::Spec->canonpath($path); # Check if the path is above the root directory return if(index($path,$root) == -1); + return if($first eq $root && $last =~ m!^(/|\\)?\.\.(/|\\)?$!); # Create short path name -- 2.34.1