diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2009-06-12 18:56:15 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2009-06-12 18:56:15 -0700 |
commit | ebad1141e86925320db2370ee49ce316c73226f5 (patch) | |
tree | e845eea5b0ea344b5e136ef3c4c5847c68019444 /lib/Vyatta | |
parent | b11c6a14c52e9c88b47b8160f1827f40d1f5cc17 (diff) | |
download | vyatta-cfg-ebad1141e86925320db2370ee49ce316c73226f5.tar.gz vyatta-cfg-ebad1141e86925320db2370ee49ce316c73226f5.zip |
add validation for bash special characters
Diffstat (limited to 'lib/Vyatta')
-rwxr-xr-x | lib/Vyatta/TypeChecker.pm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Vyatta/TypeChecker.pm b/lib/Vyatta/TypeChecker.pm index e436e0c..27d9e03 100755 --- a/lib/Vyatta/TypeChecker.pm +++ b/lib/Vyatta/TypeChecker.pm @@ -68,7 +68,8 @@ my %type_handler = ( 'hex16' => \&validate_hex_16_bits, 'hex32' => \&validate_hex_32_bits, 'ipv6_addr_param' => \&validate_ipv6_addr_param, - 'restrictive_filename' => \&validate_restrictive_filename + 'restrictive_filename' => \&validate_restrictive_filename, + 'no_bash_special' => \&validate_no_bash_special ); sub validate_ipv4 { @@ -274,6 +275,12 @@ sub validate_restrictive_filename { return (($value =~ /^[-_.a-zA-Z0-9]+$/) ? 1 : 0); } +# validate that a string does not contain bash special chars +sub validate_no_bash_special { + my $value = shift; + return (($value =~ /[;&"'`!\$><|]/) ? 0 : 1); +} + sub validateType { my ($type, $value, $quiet) = @_; if (!defined($type) || !defined($value)) { |