X-Git-Url: https://git.p6c8.net/devedit.git/blobdiff_plain/5d97440acfd02dd482d9b87d8a86521b013aea46..c2b18d37a29420fc5b1e33c19a0e69d00016c621:/modules/Tool.pm diff --git a/modules/Tool.pm b/modules/Tool.pm index 16d5d72..ccb78af 100644 --- a/modules/Tool.pm +++ b/modules/Tool.pm @@ -6,7 +6,15 @@ package Tool; # Some shared sub routines # # Author: Patrick Canterino -# Last modified: 2005-07-23 +# Last modified: 2010-12-23 +# +# Copyright (C) 1999-2000 Roland Bluethgen, Frank Schoenmann +# Copyright (C) 2003-2009 Patrick Canterino +# All Rights Reserved. +# +# This file can be distributed and/or modified under the terms of +# of the Artistic License 1.0 (see also the LICENSE file found at +# the top level of the Dev-Editor distribution). # use strict; @@ -32,6 +40,8 @@ use base qw(Exporter); encode_html equal_url file_name + in_array + is_disabled_command is_forbidden_file mode_string multi_string @@ -81,6 +91,7 @@ sub check_path($$) # Check if the path is above the root directory return if(index($path,$root) != 0); + return if(substr($path,length($root)) && not File::Spec->file_name_is_absolute(substr($path,length($root)))); # Create short path name @@ -182,6 +193,8 @@ sub dos_wildcard_match($$) { my ($pattern,$string) = @_; + return 1 if($pattern eq '*'); + # The following part is stolen from File::DosGlob # escape regex metachars but not glob chars @@ -256,6 +269,51 @@ sub file_name($) return $path; } +# in_array() +# +# Check if a value is in an array +# +# Params: 1. Value to find +# 2. Array +# +# Return: Status code (Boolean) + +sub in_array($$) +{ + my ($string,$array) = @_; + + foreach my $element(@{$array}) + { + return 1 if($string eq $element); + } + + #foreach + + return; +} + +# is_disabled_command() +# +# Check if a command is disabled +# +# Params: 1. Array Reference containing the list +# 2. Command to check +# +# Return: Status code (Boolean) + +sub is_disabled_command($$) +{ + my ($list,$command) = @_; + $command =~ s!/+$!!g; + + foreach my $entry(@$list) + { + return 1 if(lc($command) eq lc($entry)); + } + + return; +} + # is_forbidden_file() # # Check if a file is in the list of forbidden files