Skip to content

Commit

Permalink
[backend] fix request trashing on reopen. Also validating requests no…
Browse files Browse the repository at this point in the history
…w in backend more correctly.
  • Loading branch information
adrianschroeter committed Dec 21, 2011
1 parent 63df288 commit 5157f15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/backend/BSVerify.pm
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ sub verify_request {
verify_num($req->{'id'}) if exists $req->{'id'};
die("request must contain a state\n") unless $req->{'state'};
die("request must contain a state name\n") unless $req->{'state'}->{'name'};
die("request must contain a state who\n") unless $req->{'state'}->{'who'};
die("request must contain a state when\n") unless $req->{'state'}->{'when'};
die("request contains unknown state '$req->{'state'}->{'name'}'\n") unless $req_states{$req->{'state'}->{'name'}};
verify_num($req->{'state'}->{'superseded_by'}) if exists $req->{'state'}->{'superseded_by'};

Expand All @@ -314,6 +316,11 @@ sub verify_request {
}
die("request must contain an action\n") unless $actions && @$actions;
my %pkgchange;
for my $h (@{$req->{'history'} ||[]}) {
die("history element has no 'who' attribute\n") unless $h->{'who'};
die("history element has no 'when' attribute\n") unless $h->{'when'};
die("history element has no 'name' attribute\n") unless $h->{'name'};
}
for my $r (@$actions) {
die("request action has no type\n") unless $r->{'type'};
if ($r->{'type'} eq 'delete') {
Expand Down
4 changes: 2 additions & 2 deletions src/backend/bs_srcserver
Original file line number Diff line number Diff line change
Expand Up @@ -5742,13 +5742,13 @@ sub createrequest {
$req->{'state'}->{'name'} = 'new';
$req->{'state'}->{'name'} = 'review' if defined($req->{'review'});

BSVerify::verify_request($req);
die("request must not contain an id\n") if $req->{'id'};
die("request must not contain a history\n") if $req->{'history'};
die("request must not be created by anonymous\n") unless defined $cgi->{'user'};
$req->{'state'}->{'who'} = $cgi->{'user'};
my @lt = localtime(time());
$req->{'state'}->{'when'} = sprintf("%04d-%02d-%02dT%02d:%02d:%02d", $lt[5] + 1900, $lt[4] + 1, @lt[3,2,1,0]);
BSVerify::verify_request($req);
$req->{'id'} = nextreqid();
writereq(undef, $req);

Expand Down Expand Up @@ -5890,7 +5890,7 @@ sub postrequest {
$r->{'when'} = $mytime;
$r->{'who'} = $cgi->{'user'} if defined $cgi->{'user'};
$r->{'comment'} = $cgi->{'comment'} if defined($cgi->{'comment'});
$req->{'state'} = {'name' => 'review'};
$req->{'state'}->{'name'} = 'review';
}
}
}
Expand Down

0 comments on commit 5157f15

Please sign in to comment.