my @versions = grep $_->[0] eq 'version', @$directive;
if (scalar @versions == 1) {
- $versions[0][1] =~ /^(\d+\.\d+)$/
- or push @errors, "invalid version $versions[0][1]";
- my $val = $1; # so far so good
+ if ($versions[0][1] =~ /^(\d+\.\d+)$/) {
+ my $val = $1; # so far so good
- # We only support version 1.1/1.2 right now!
- push @errors, "invalid version $val, not supported"
- if (($val ne '1.1') and ($val ne '1.2'));
+ # We only support version 1.1/1.2 right now!
+ push @errors, "invalid version $val, not supported"
+ if (($val ne '1.1') and ($val ne '1.2'));
- $header{version} = $val; # TODO: parse?
+ $header{version} = $val; # TODO: parse?
+ } else {
+ # version value does not match required pattern
+ push @errors, "invalid version $versions[0][1]";
+ }
} elsif (scalar @versions > 1) {
push @errors, "invalid multiple version elements";
} else { # no version at all; no longer allowed
my $tainted_cmd = lc $item->[0];
my $tainted_val = $item->[1];
- if ($tainted_cmd eq 'directory') {
+ if (!$tainted_val && !($tainted_cmd =~ m/^comment|^no-op/)) {
+ push @errors, "invalid $tainted_cmd element with no value";
+ } elsif ($tainted_cmd eq 'directory') {
unless ($tainted_val =~ m/^($RE_filename_relative)$/) {
push @errors, "invalid directory $tainted_val";
next;