6 use POSIX qw(strftime tzset);
8 #require '/usr/lib/debbugs/errorlib';
9 require '/usr/lib/debbugs/common.pl';
10 #require '/debian/home/ajt/newajbug/common.pl';
12 require '/etc/debbugs/config';
13 require '/etc/debbugs/text';
15 use vars(qw($gHTMLTail $gWebDomain));
18 # Parse query string. I could use CGI.pm here, but it is 6 thousand
19 # lines long and very expensive. I want light-weight.
20 my ($in, $key, $val, %ret);
21 if (defined $ENV{"QUERY_STRING"} && $ENV{"QUERY_STRING"} ne "") {
22 $in=$ENV{QUERY_STRING};
23 } elsif(defined $ENV{"REQUEST_METHOD"}
24 && $ENV{"REQUEST_METHOD"} eq "POST")
26 read(STDIN,$in,$ENV{CONTENT_LENGTH});
30 foreach (split(/&/,$in)) {
32 ($key, $val) = split(/=/,$_,2);
33 $key=~s/%(..)/pack("c",hex($1))/ge;
34 $val=~s/%(..)/pack("c",hex($1))/ge;
40 my %param = readparse();
44 my %maintainer = getmaintainers();
46 my $ref = $param{'bug'} || quit("No bug number");
47 my $msg = $param{'msg'} || "";
48 my $boring = ($param{'boring'} || 'no') eq 'yes';
49 my $reverse = ($param{'reverse'} || 'no') eq 'yes';
51 my %status = getbugstatus($ref) or &quit("Couldn't get bug status: $!");
64 my $dtime = strftime "%a, %e %b %Y %T UTC", localtime;
65 $tail_html = $debbugs::gHTMLTail;
66 $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
70 $tpack = lc $status{'package'};
71 $tpack =~ s/[^-+._a-z0-9()].*$//;
73 if ($status{severity} eq 'normal') {
75 #} elsif (grep($status{severity} eq $_, @strongseverities)) {
76 # $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
78 $showseverity = "Severity: <em>$status{severity}</em>;\n";
81 $indexentry .= $showseverity;
82 $indexentry .= "Package: <A HREF=\"" . pkgurl($status{package}) . "\">"
83 .htmlsanit($status{package})."</A>;\n";
85 $indexentry .= ";Reported by: ".htmlsanit($status{originator});
86 $indexentry .= ";\nTags: <strong>"
87 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
89 if length($status{tags});
91 my @merged= split(/ /,$status{mergedwith});
93 my $mseparator= ";\nmerged with ";
95 $indexentry .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
100 my $dummy = strftime "%a, %e %b %Y %T UTC", localtime($status{date});
101 $submitted = ";\ndated ".$dummy;
103 if (length($status{done})) {
104 $indexentry .= ";\n<strong>Done:</strong> ".htmlsanit($status{done});
105 } elsif (length($status{forwarded})) {
106 $indexentry .= ";\n<strong>Forwarded</strong> to ".htmlsanit($status{forwarded});
109 my ($short, $tmaint);
110 $short = $ref; $short =~ s/^\d+/#$&/;
111 $tmaint = defined($maintainer{$tpack}) ? $maintainer{$tpack} : '(unknown)';
112 $descriptivehead= $indexentry.$submitted.";\nMaintainer for $status{package} is\n".
113 '<A href="http://'.$debbugs::gWebDomain.'/db/ma/l'.&maintencoded($tmaint).'.html">'.htmlsanit($tmaint).'</A>.';
115 my $buglog = buglog($ref);
116 open L, "<$buglog" or &quit("open log for $ref: $!");
121 my $suppressnext = 0;
127 my $normstate= 'kill-init';
129 while(my $line = <L>) {
131 if ($line =~ m/^.$/ and 1 <= ord($line) && ord($line) <= 7) {
134 my $statenum = ord($line);
136 $newstate = 'autocheck' if ($statenum == 1);
137 $newstate = 'recips' if ($statenum == 2);
138 $newstate = 'kill-end' if ($statenum == 3);
139 $newstate = 'go' if ($statenum == 5);
140 $newstate = 'html' if ($statenum == 6);
141 $newstate = 'incoming-recv' if ($statenum == 7);
143 # disallowed transitions:
144 $_ = "$normstate $newstate";
145 unless (m/^(go|go-nox|html) kill-end$/
146 || m/^(kill-init|kill-end) (incoming-recv|autocheck|recips|html)$/
147 || m/^kill-body go$/)
149 &quit("$ref: Transition from $normstate to $newstate at $linenum disallowed");
152 if ($newstate eq 'go') {
156 if ($newstate eq 'html') {
160 if ($newstate eq 'kill-end') {
163 if $normstate eq 'go' || $normstate eq 'go-nox';
165 if ($normstate eq 'html') {
166 $this .= " <em><A href=\"" . bugurl($ref, "msg=$xmessage") . "\">Full text</A> available.</em>";
171 if ($suppressnext && $normstate ne 'html');
173 $show = ($xmessage == $msg) if ($msg);
177 $log = "$this\n<hr>$log";
179 $log .= "$this\n<hr>\n";
183 $xmessage++ if ($normstate ne 'html');
185 $suppressnext = $normstate eq 'html';
188 $normstate = $newstate;
193 if ($normstate eq 'incoming-recv') {
196 m/^Received: \(at (\S+)\) by (\S+)\;/
197 || &quit("bad line \`$pl' in state incoming-recv");
198 $this = "<h2>Message received at ".htmlsanit("$1\@$2")
199 . ":</h2><br>\n<pre>\n$_";
201 } elsif ($normstate eq 'html') {
203 } elsif ($normstate eq 'go') {
204 $this .= htmlsanit($_);
205 } elsif ($normstate eq 'go-nox') {
207 $this .= htmlsanit($_);
208 } elsif ($normstate eq 'recips') {
210 $this = "<h2>Message sent:</h2><br>\n";
213 $this = "<h2>Message sent to ".htmlsanit($_).":</h2><br>\n";
215 $normstate= 'kill-body';
216 } elsif ($normstate eq 'autocheck') {
217 next if !m/^X-Debian-Bugs(-\w+)?: This is an autoforward from (\S+)/;
218 $normstate= 'autowait';
219 $this = "<h2>Message received at $2:</h2><br>\n";
220 } elsif ($normstate eq 'autowait') {
222 $normstate= 'go-nox';
225 &quit("$ref state $normstate line \`$_'");
228 &quit("$ref state $normstate at end") unless $normstate eq 'kill-end';
231 print "Content-Type: text/html\n\n";
233 print "<HTML><HEAD><TITLE>\n" .
234 "$debbugs::gProject $debbugs::gBug report logs - $short\n" .
235 "</TITLE></HEAD>\n" .
236 '<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">' .
238 print "<H1>" . "$debbugs::gProject $debbugs::gBug report logs - $short" .
239 "<BR>" . htmlsanit($status{subject}) . "</H1>\n";
241 print "$descriptivehead\n";
246 print "</BODY></HTML>\n";