my $filename;
my $cnt = 0; # TODO: remove this
+ { # Extract version first, since directive elements may be in any order.
+ my @versions = grep $_->[0] eq 'version', @$directive;
+
+ if (scalar @versions == 1) {
+ $versions[0][1] =~ /^(\d+\.\d+)$/
+ or fatal("invalid version $versions[0][1]",1,$directive_file_contents);
+ my $val = $1; # so far so good
+
+ # We only support version 1.1/1.2 right now!
+ fatal("invalid version $val, not supported",1,$directive_file_contents)
+ if (($val ne '1.1') and ($val ne '1.2'));
+
+ $header{version} = $val; # TODO: parse?
+ $info{"version"} = $val; #ok.
+ } elsif (scalar @versions > 1) {
+ fatal("invalid multiple version elements",1,$directive_file_contents);
+ } else { # no version at all; no longer allowed
+ # This will be caught later, when the operation list is validated.
+ }
+ }
+
foreach my $item (@$directive) {
my $tainted_cmd = lc $item->[0];
my $tainted_val = $item->[1];
$filename = $val;
$info{"filename"} = {"value" => $val, "order" => $cnt++}; # ok.
} elsif ($tainted_cmd eq 'version') {
- $tainted_val =~ /^(\d+\.\d+)$/
- or fatal("invalid version $tainted_val",1,$directive_file_contents);
- my $val = $1; # so far so good
-
- # We only support version 1.1/1.2 right now!
- fatal("invalid version $val, not supported",1,$directive_file_contents)
- if (($val ne '1.1') and ($val ne '1.2'));
-
- # Only let them specify one version directive.
- fatal("invalid second version $val, have $info{version}",
- 1,$directive_file_contents)
- if exists $info{"version"};
-
- $header{version} = $val; # TODO: parse?
- $info{"version"} = $val; #ok.
+ # already handled above
} elsif ($tainted_cmd eq 'symlink') {
$tainted_val =~ /^($RE_filename_relative)\s+($RE_filename_relative)$/
or fatal("invalid parameters for symlink command: $tainted_val",