From: pcanterino <> Date: Fri, 7 Jan 2005 11:10:45 +0000 (+0000) Subject: Let's hope, check_path() is now working properly. X-Git-Tag: version_2_3~3 X-Git-Url: https://git.p6c8.net/devedit.git/commitdiff_plain/0fb9dcffcc2a1be81de150bae084e195c5f66658 Let's hope, check_path() is now working properly. Maybe we should switch to Win32::GetFullPathName() on Windows... --- diff --git a/modules/Tool.pm b/modules/Tool.pm index dc11571..0b1159d 100644 --- a/modules/Tool.pm +++ b/modules/Tool.pm @@ -6,7 +6,7 @@ package Tool; # Some shared sub routines # # Author: Patrick Canterino -# Last modified: 2005-01-06 +# Last modified: 2005-01-07 # use strict; @@ -61,9 +61,32 @@ sub check_path($$) # We extract the last part of the path and create the absolute path my $first = upper_path($path); + $first = abs_path($first); + my $last = file_name($path); + $last = '' if($last eq '.'); + + if($last eq '..') + { + $first = upper_path($first); + $last = ''; + } + elsif($^O eq 'MSWin32' && $last =~ m!^\.\.\.+$!) + { + # Windows allows to go upwards in a path using things like + # "..." and "...." and so on + + for(my $x=0;$xcanonpath($first); @@ -72,7 +95,6 @@ sub check_path($$) # Check if the path is above the root directory return if(index($path,$root) != 0); - return if($first eq $root && ($last eq '..' || ($^O eq 'MSWin32' && $last =~ m!^\.\.+$!))); # Create short path name