6 use POSIX qw(strftime tzset);
8 #require '/usr/lib/debbugs/errorlib';
11 require '/etc/debbugs/config';
12 require '/etc/debbugs/text';
14 use vars(qw($gHTMLTail $gWebDomain));
16 my %param = readparse();
20 my %maintainer = %{getmaintainers()};
22 my $ref = $param{'bug'} || quit("No bug number");
23 my $msg = $param{'msg'} || "";
24 my $boring = ($param{'boring'} || 'no') eq 'yes';
25 my $reverse = ($param{'reverse'} || 'no') eq 'yes';
27 my %status = %{getbugstatus($ref)} or &quit("Couldn't get bug status: $!");
40 my $dtime = strftime "%a, %e %b %Y %T UTC", localtime;
41 $tail_html = $debbugs::gHTMLTail;
42 $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
46 $tpack = lc $status{'package'};
47 $tpack =~ s/[^-+._a-z0-9()].*$//;
49 if ($status{severity} eq 'normal') {
51 #} elsif (grep($status{severity} eq $_, @strongseverities)) {
52 # $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
54 $showseverity = "Severity: <em>$status{severity}</em>;\n";
57 $indexentry .= $showseverity;
58 $indexentry .= "Package: <A HREF=\"" . pkgurl($status{package}) . "\">"
59 .htmlsanit($status{package})."</A>;\n";
61 $indexentry .= ";Reported by: ".htmlsanit($status{originator});
62 $indexentry .= ";\nTags: <strong>"
63 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
65 if length($status{tags});
67 my @merged= split(/ /,$status{mergedwith});
69 my $mseparator= ";\nmerged with ";
71 $indexentry .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
76 my $dummy = strftime "%a, %e %b %Y %T UTC", localtime($status{date});
77 $submitted = ";\ndated ".$dummy;
79 if (length($status{done})) {
80 $indexentry .= ";\n<strong>Done:</strong> ".htmlsanit($status{done});
81 } elsif (length($status{forwarded})) {
82 $indexentry .= ";\n<strong>Forwarded</strong> to ".htmlsanit($status{forwarded});
86 $short = $ref; $short =~ s/^\d+/#$&/;
87 $tmaint = defined($maintainer{$tpack}) ? $maintainer{$tpack} : '(unknown)';
88 $descriptivehead= $indexentry.$submitted.";\nMaintainer for $status{package} is\n".
89 '<A href="http://'.$debbugs::gWebDomain.'/db/ma/l'.&maintencoded($tmaint).'.html">'.htmlsanit($tmaint).'</A>.';
91 my $buglog = buglog($ref);
92 open L, "<$buglog" or &quit("open log for $ref: $!");
103 my $normstate= 'kill-init';
105 while(my $line = <L>) {
107 if ($line =~ m/^.$/ and 1 <= ord($line) && ord($line) <= 7) {
110 my $statenum = ord($line);
112 $newstate = 'autocheck' if ($statenum == 1);
113 $newstate = 'recips' if ($statenum == 2);
114 $newstate = 'kill-end' if ($statenum == 3);
115 $newstate = 'go' if ($statenum == 5);
116 $newstate = 'html' if ($statenum == 6);
117 $newstate = 'incoming-recv' if ($statenum == 7);
119 # disallowed transitions:
120 $_ = "$normstate $newstate";
121 unless (m/^(go|go-nox|html) kill-end$/
122 || m/^(kill-init|kill-end) (incoming-recv|autocheck|recips|html)$/
123 || m/^kill-body go$/)
125 &quit("$ref: Transition from $normstate to $newstate at $linenum disallowed");
128 if ($newstate eq 'go') {
132 if ($newstate eq 'html') {
136 if ($newstate eq 'kill-end') {
139 if $normstate eq 'go' || $normstate eq 'go-nox';
141 if ($normstate eq 'html') {
142 $this .= " <em><A href=\"" . bugurl($ref, "msg=$xmessage") . "\">Full text</A> available.</em>";
147 if ($suppressnext && $normstate ne 'html');
149 $show = ($xmessage == $msg) if ($msg);
153 $log = "$this\n<hr>$log";
155 $log .= "$this\n<hr>\n";
159 $xmessage++ if ($normstate ne 'html');
161 $suppressnext = $normstate eq 'html';
164 $normstate = $newstate;
169 if ($normstate eq 'incoming-recv') {
172 m/^Received: \(at (\S+)\) by (\S+)\;/
173 || &quit("bad line \`$pl' in state incoming-recv");
174 $this = "<h2>Message received at ".htmlsanit("$1\@$2")
175 . ":</h2><br>\n<pre>\n$_";
177 } elsif ($normstate eq 'html') {
179 } elsif ($normstate eq 'go') {
180 $this .= htmlsanit($_);
181 } elsif ($normstate eq 'go-nox') {
183 $this .= htmlsanit($_);
184 } elsif ($normstate eq 'recips') {
186 $this = "<h2>Message sent:</h2><br>\n";
189 $this = "<h2>Message sent to ".htmlsanit($_).":</h2><br>\n";
191 $normstate= 'kill-body';
192 } elsif ($normstate eq 'autocheck') {
193 next if !m/^X-Debian-Bugs(-\w+)?: This is an autoforward from (\S+)/;
194 $normstate= 'autowait';
195 $this = "<h2>Message received at $2:</h2><br>\n";
196 } elsif ($normstate eq 'autowait') {
198 $normstate= 'go-nox';
201 &quit("$ref state $normstate line \`$_'");
204 &quit("$ref state $normstate at end") unless $normstate eq 'kill-end';
207 print "Content-Type: text/html\n\n";
209 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
210 print "<HTML><HEAD>\n" .
211 "<TITLE>$debbugs::gProject $debbugs::gBug report logs - $short</TITLE>\n" .
213 '<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">' .
215 print "<H1>" . "$debbugs::gProject $debbugs::gBug report logs - <A HREF=\"mailto:$ref\@bugs.debian.org\">$short</A>" .
216 "<BR>" . htmlsanit($status{subject}) . "</H1>\n";
218 print "$descriptivehead\n";
223 print "</BODY></HTML>\n";