) {
- $linenum++;
- if ($line =~ m/^.$/ and 1 <= ord($line) && ord($line) <= 7) {
- # state transitions
- my $newstate;
- my $statenum = ord($line);
-
- $newstate = 'autocheck' if ($statenum == 1);
- $newstate = 'recips' if ($statenum == 2);
- $newstate = 'kill-end' if ($statenum == 3);
- $newstate = 'go' if ($statenum == 5);
- $newstate = 'html' if ($statenum == 6);
- $newstate = 'incoming-recv' if ($statenum == 7);
-
- # disallowed transitions:
- $_ = "$normstate $newstate";
- unless (m/^(go|go-nox|html) kill-end$/
- || m/^(kill-init|kill-end) (incoming-recv|autocheck|recips|html)$/
- || m/^kill-body go$/)
- {
- &quit("$ref: Transition from $normstate to $newstate at $linenum disallowed");
- }
-
- if ($newstate eq 'go') {
- $this .= "\n";
- }
-
- if ($newstate eq 'html') {
- $this = '';
- }
-
- if ($newstate eq 'kill-end') {
-
- $this .= "
\n"
- if $normstate eq 'go' || $normstate eq 'go-nox';
-
- if ($normstate eq 'html') {
- $this .= " Full text available.";
- }
-
- my $show = 1;
- $show = $boring
- if ($suppressnext && $normstate ne 'html');
-
- $show = ($xmessage == $msg) if ($msg);
-
- if ($show) {
- if ($reverse) {
- $log = "$this\n
$log";
- } else {
- $log .= "$this\n
\n";
- }
- }
-
- $xmessage++ if ($normstate ne 'html');
-
- $suppressnext = $normstate eq 'html';
- }
-
- $normstate = $newstate;
- next;
- }
-
- $_ = $line;
- if ($normstate eq 'incoming-recv') {
- my $pl= $_;
- $pl =~ s/\n+$//;
- m/^Received: \(at (\S+)\) by (\S+)\;/
- || &quit("bad line \`$pl' in state incoming-recv");
- $this = "Message received at ".htmlsanit("$1\@$2")
- . ":
\n\n$_";
- $normstate= 'go';
- } elsif ($normstate eq 'html') {
- $this .= $_;
- } elsif ($normstate eq 'go') {
- $this .= htmlsanit($_);
- } elsif ($normstate eq 'go-nox') {
- next if !s/^X//;
- $this .= htmlsanit($_);
- } elsif ($normstate eq 'recips') {
- if (m/^-t$/) {
- $this = "Message sent:
\n";
- } else {
- s/\04/, /g; s/\n$//;
- $this = "Message sent to ".htmlsanit($_).":
\n";
- }
- $normstate= 'kill-body';
- } elsif ($normstate eq 'autocheck') {
- next if !m/^X-Debian-Bugs(-\w+)?: This is an autoforward from (\S+)/;
- $normstate= 'autowait';
- $this = "Message received at $2:
\n";
- } elsif ($normstate eq 'autowait') {
- next if !m/^$/;
- $normstate= 'go-nox';
- $this .= "\n";
- } else {
- &quit("$ref state $normstate line \`$_'");
- }
-}
-&quit("$ref state $normstate at end") unless $normstate eq 'kill-end';
-close(L);
-
-print "Content-Type: text/html\n\n";
-
-print "\n" .
- "$debbugs::gProject $debbugs::gBug report logs - $short\n" .
- "\n" .
- '' .
- "\n";
-print "" . "$debbugs::gProject $debbugs::gBug report logs - $short" .
- "
" . htmlsanit($status{subject}) . "
\n";
-
-print "$descriptivehead\n";
-print "
";
-print "$log";
-print $tail_html;
-
-print "\n";
-
-exit 0;
+# All of the below should be turned into a template
+
+my %maintainer = %{getmaintainers()};
+my %pkgsrc = %{getpkgsrc()};
+
+my $indexentry;
+my $showseverity;
+
+my $tpack;
+my $tmain;
+
+my $dtime = strftime "%a, %e %b %Y %T UTC", gmtime;
+
+unless (%status) {
+ print $q->header(-type => "text/html",
+ -charset => 'utf-8',
+ (length $mtime)?(-last_modified => $mtime):(),
+ );
+ print fill_in_template(template=>'cgi/no_such_bug',
+ variables => {modify_time => $dtime,
+ bug_num => $ref,
+ },
+ );
+ exit 0;
+}
+
+#$|=1;
+
+my %package;
+my @packages = make_list($status{package});
+
+foreach my $pkg (@packages) {
+ if ($pkg =~ /^src\:/) {
+ my ($srcpkg) = $pkg =~ /^src:(.*)/;
+ $package{$pkg} = {maintainer => exists($maintainer{$srcpkg}) ? $maintainer{$srcpkg} : '(unknown)',
+ source => $srcpkg,
+ package => $pkg,
+ is_source => 1,
+ };
+ }
+ else {
+ $package{$pkg} = {maintainer => exists($maintainer{$pkg}) ? $maintainer{$pkg} : '(unknown)',
+ exists($pkgsrc{$pkg}) ? (source => $pkgsrc{$pkg}) : (),
+ package => $pkg,
+ };
+ }
+}
+
+# fixup various bits of the status
+$status{tags_array} = [sort(make_list($status{tags}))];
+$status{date_text} = strftime('%a, %e %b %Y %T UTC', gmtime($status{date}));
+$status{mergedwith_array} = [make_list($status{mergedwith})];
+
+
+my $version_graph = '';
+if (@{$status{found_versions}} or @{$status{fixed_versions}}) {
+ $version_graph = q(
};
+}
+
+
+
+my @blockedby= make_list($status{blockedby});
+$status{blockedby_array} = [];
+if (@blockedby && $status{"pending"} ne 'fixed' && ! length($status{done})) {
+ for my $b (@blockedby) {
+ my %s = %{get_bug_status($b)};
+ next if $s{"pending"} eq 'fixed' || length $s{done};
+ push @{$status{blockedby_array}},{bug_num => $b, subject => $s{subject}, status => \%s};
+ }
+}
+
+my @blocks= make_list($status{blocks});
+$status{blocks_array} = [];
+if (@blocks && $status{"pending"} ne 'fixed' && ! length($status{done})) {
+ for my $b (@blocks) {
+ my %s = %{get_bug_status($b)};
+ next if $s{"pending"} eq 'fixed' || length $s{done};
+ push @{$status{blocks_array}}, {bug_num => $b, subject => $s{subject}, status => \%s};
+ }
+}
+
+if ($buglog !~ m#^\Q$gSpoolDir/db#) {
+ $status{archived} = 1;
+}
+
+my $descriptivehead = $indexentry;
+
+print $q->header(-type => "text/html",
+ -charset => 'utf-8',
+ (length $mtime)?(-last_modified => $mtime):(),
+ );
+
+print fill_in_template(template => 'cgi/bugreport',
+ variables => {status => \%status,
+ package => \%package,
+ log => $log,
+ bug_num => $ref,
+ version_graph => $version_graph,
+ msg => $msg,
+ isstrongseverity => \&Debbugs::Status::isstrongseverity,
+ html_escape => \&Debbugs::CGI::html_escape,
+ looks_like_number => \&Scalar::Util::looks_like_number,
+ make_list => \&Debbugs::Common::make_list,
+ },
+ hole_var => {'&package_links' => \&Debbugs::CGI::package_links,
+ '&bug_links' => \&Debbugs::CGI::bug_links,
+ '&version_url' => \&Debbugs::CGI::version_url,
+ '&bug_url' => \&Debbugs::CGI::bug_url,
+ '&strftime' => \&POSIX::strftime,
+ '&maybelink' => \&Debbugs::CGI::maybelink,
+ },
+ );