X-Git-Url: https://git.p6c8.net/devedit.git/blobdiff_plain/dff53f21c8fccc7585f785fec893a5773e78a1b6..ee2055d94dacff3fa49097a0a2b3a1347cdbb9de:/modules/Tool.pm?ds=inline diff --git a/modules/Tool.pm b/modules/Tool.pm index dc11571..9ba39c2 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,18 +61,39 @@ 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 + + my $count = length($last)-1; - $first = abs_path($first); - $path = $first.'/'.$last; + for(my $x=0;$x<$count;$x++) + { + unless($first =~ m!^[a-z]{1}:(/|\\)$!i) + { + $first = upper_path($first); + } + } + + $last = ''; + } - $first = File::Spec->canonpath($first); - $path = File::Spec->canonpath($path); + $path = File::Spec->canonpath($first.'/'.$last); # 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