Commit 7173ee72 authored by Maiken's avatar Maiken

Merge branch 'fix3838' into 'master'

Fix for BUGZ-3838 - Ensure space trimming in block names all over the code

See merge request nordugrid/arc!912
parents c371209a bbb8cf21
......@@ -475,6 +475,40 @@ sub read_json_config {
return $config;
}
#
# Removes spaces at beginning and end from all config values
# and config names (such as queue:\s\squeuename\s*)
#
sub strip_spaces {
my ($jsonconf) = @_;
for my $key (keys %{$jsonconf}) {
# recur if inner values
if (ref($jsonconf->{$key}) eq 'HASH') {
strip_spaces($jsonconf->{$key});
} elsif (ref($jsonconf->{$key}) eq 'ARRAY') {
# strip spaces from array elements
for my $item (@{$jsonconf->{$key}}) {
$item =~ s/^\s+|\s+$//g;
}
} elsif ($jsonconf->{$key} =~ /^\s*(.*)\s*$/) {
my $newvalue = $1;
$newvalue =~ s/^\s+|\s+$//g;
$jsonconf->{$key} = $newvalue;
}
# change key once back from recursion if it contains spaces
if ($key =~ /\s*(queue|authgroup)\s*:\s*(.*)\s*/) {
my $prefix = "$1:";
my $stripstring = $2;
$stripstring =~ s/^\s+|\s+$//g;
my $newkey="$prefix$stripstring";
$jsonconf->{$newkey} = $jsonconf->{$key};
# not needed as the reference is copied. But I don't trust it.
#delete $jsonconf->{$key};
}
}
}
#
# Reads the json config file passed as the first argument and produces a config
# hash conforming to $config_schema.
......@@ -484,7 +518,10 @@ sub build_config_from_json {
my $jsonconf = read_json_config($file);
strip_spaces($jsonconf);
set_defaults($jsonconf);
# Those values that are the same as in arc.conf will
# be copied and checked.
......@@ -1007,6 +1044,8 @@ sub getValueOf ($$$){
close $parserout;
}
# remove blank spaces before and after
$value =~ s/^\s+|\s+$//g;
# strip trailing newline
chomp $value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment