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 .= ";\nKeywords: ".htmlsanit($status{keywords})
87 if length($status{keywords});
89 my @merged= split(/ /,$status{mergedwith});
91 my $mseparator= ";\nmerged with ";
93 $indexentry .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
98 my $dummy = strftime "%a, %e %b %Y %T UTC", localtime($status{date});
99 $submitted = ";\ndated ".$dummy;
101 if (length($status{done})) {
102 $indexentry .= ";\n<strong>Done:</strong> ".htmlsanit($status{done});
103 } elsif (length($status{forwarded})) {
104 $indexentry .= ";\n<strong>Forwarded</strong> to ".htmlsanit($status{forwarded});
107 my ($short, $tmaint);
108 $short = $ref; $short =~ s/^\d+/#$&/;
109 $tmaint = defined($maintainer{$tpack}) ? $maintainer{$tpack} : '(unknown)';
110 $descriptivehead= $indexentry.$submitted.";\nMaintainer for $status{package} is\n".
111 '<A href="http://'.$debbugs::gWebDomain.'/db/ma/l'.&maintencoded($tmaint).'.html">'.htmlsanit($tmaint).'</A>.';
113 my $buglog = buglog($ref);
114 open L, "<$buglog" or &quit("open log for $ref: $!");
119 my $suppressnext = 0;
125 my $normstate= 'kill-init';
127 while(my $line = <L>) {
129 if ($line =~ m/^.$/ and 1 <= ord($line) && ord($line) <= 7) {
132 my $statenum = ord($line);
134 $newstate = 'autocheck' if ($statenum == 1);
135 $newstate = 'recips' if ($statenum == 2);
136 $newstate = 'kill-end' if ($statenum == 3);
137 $newstate = 'go' if ($statenum == 5);
138 $newstate = 'html' if ($statenum == 6);
139 $newstate = 'incoming-recv' if ($statenum == 7);
141 # disallowed transitions:
142 $_ = "$normstate $newstate";
143 unless (m/^(go|go-nox|html) kill-end$/
144 || m/^(kill-init|kill-end) (incoming-recv|autocheck|recips|html)$/
145 || m/^kill-body go$/)
147 &quit("$ref: Transition from $normstate to $newstate at $linenum disallowed");
150 if ($newstate eq 'go') {
154 if ($newstate eq 'html') {
158 if ($newstate eq 'kill-end') {
161 if $normstate eq 'go' || $normstate eq 'go-nox';
163 if ($normstate eq 'html') {
164 $this .= " <em><A href=\"" . bugurl($ref, "msg=$xmessage") . "\">Full text</A> available.</em>";
169 if ($suppressnext && $normstate ne 'html');
171 $show = ($xmessage == $msg) if ($msg);
175 $log = "$this\n<hr>$log";
177 $log .= "$this\n<hr>\n";
181 $xmessage++ if ($normstate ne 'html');
183 $suppressnext = $normstate eq 'html';
186 $normstate = $newstate;
191 if ($normstate eq 'incoming-recv') {
194 m/^Received: \(at (\S+)\) by (\S+)\;/
195 || &quit("bad line \`$pl' in state incoming-recv");
196 $this = "<h2>Message received at ".htmlsanit("$1\@$2")
197 . ":</h2><br>\n<pre>\n$_";
199 } elsif ($normstate eq 'html') {
201 } elsif ($normstate eq 'go') {
202 $this .= htmlsanit($_);
203 } elsif ($normstate eq 'go-nox') {
205 $this .= htmlsanit($_);
206 } elsif ($normstate eq 'recips') {
208 $this = "<h2>Message sent:</h2><br>\n";
211 $this = "<h2>Message sent to ".htmlsanit($_).":</h2><br>\n";
213 $normstate= 'kill-body';
214 } elsif ($normstate eq 'autocheck') {
215 next if !m/^X-Debian-Bugs(-\w+)?: This is an autoforward from (\S+)/;
216 $normstate= 'autowait';
217 $this = "<h2>Message received at $2:</h2><br>\n";
218 } elsif ($normstate eq 'autowait') {
220 $normstate= 'go-nox';
223 &quit("$ref state $normstate line \`$_'");
226 &quit("$ref state $normstate at end") unless $normstate eq 'kill-end';
229 print "Content-Type: text/html\n\n";
231 print "<HTML><HEAD><TITLE>\n" .
232 "$debbugs::gProject $debbugs::gBug report logs - $short\n" .
233 "</TITLE></HEAD>\n" .
234 '<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">' .
236 print "<H1>" . "$debbugs::gProject $debbugs::gBug report logs - $short" .
237 "<BR>" . htmlsanit($status{subject}) . "</H1>\n";
239 print "$descriptivehead\n";
244 print "</BODY></HTML>\n";