3 my $common_archive = 0;
4 my $common_repeatmerged = 1;
5 my %common_include = ();
6 my %common_exclude = ();
12 if ($opt eq "archive") { $common_archive = $val; }
13 if ($opt eq "repeatmerged") { $common_repeatmerged = $val; }
14 if ($opt eq "exclude") { %common_exclude = %{$val}; }
15 if ($opt eq "include") { %common_include = %{$val}; }
19 my ($in, $key, $val, %ret);
20 if (defined $ENV{"QUERY_STRING"} && $ENV{"QUERY_STRING"} ne "") {
21 $in=$ENV{QUERY_STRING};
22 } elsif(defined $ENV{"REQUEST_METHOD"}
23 && $ENV{"REQUEST_METHOD"} eq "POST")
25 read(STDIN,$in,$ENV{CONTENT_LENGTH});
29 foreach (split(/&/,$in)) {
31 ($key, $val) = split(/=/,$_,2);
32 $key=~s/%(..)/pack("c",hex($1))/ge;
33 $val=~s/%(..)/pack("c",hex($1))/ge;
36 $debug = 1 if ($ret{"debug"} eq "aj");
42 print "Content-Type: text/html\n\n";
43 print "<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\n";
44 print "An error occurred. Dammit.\n";
45 print "Error was: $msg.\n";
46 print "</BODY></HTML>\n";
52 # my $Archive = $common_archive ? "archive" : "";
53 # print header . start_html("Sorry");
54 # print "Sorry bug #$msg doesn't seem to be in the $Archive database.\n";
61 my %status = getbugstatus($ref);
62 return htmlindexentrystatus(%status) if (%status);
66 sub htmlindexentrystatus {
72 if ($status{severity} eq 'normal') {
74 } elsif (grep($status{severity} eq $_, @debbugs::gStrongSeverities)) {
75 $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
77 $showseverity = "Severity: <em>$status{severity}</em>;\n";
80 $result .= "Package: <a href=\"" . pkgurl($status{"package"}) . "\">"
81 . "<strong>" . htmlsanit($status{"package"}) . "</strong></a>;\n"
82 if (length($status{"package"}));
83 $result .= $showseverity;
84 $result .= "Reported by: " . htmlsanit($status{originator});
85 $result .= ";\nTags: <strong>"
86 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
88 if (length($status{tags}));
90 my @merged= split(/ /,$status{mergedwith});
91 my $mseparator= ";\nmerged with ";
93 $result .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
97 if (length($status{done})) {
98 $result .= ";\n<strong>Done:</strong> " . htmlsanit($status{done});
99 } elsif (length($status{forwarded})) {
100 $result .= ";\n<strong>Forwarded</strong> to "
101 . htmlsanit($status{forwarded});
103 my $daysold = int((time - $status{date}) / 86400); # seconds to days
107 $font = "em" if ($daysold > 30);
108 $font = "strong" if ($daysold > 60);
109 $efont = "</$font>" if ($font);
110 $font = "<$font>" if ($font);
112 my $yearsold = int($daysold / 364);
113 $daysold = $daysold - $yearsold * 364;
115 $result .= ";\n $font";
116 $result .= "1 year and " if ($yearsold == 1);
117 $result .= "$yearsold years and " if ($yearsold > 1);
118 $result .= "1 day old" if ($daysold == 1);
119 $result .= "$daysold days old" if ($daysold != 1);
130 my $ref = shift || "";
131 my $params = "submitter=" . emailfromrfc822($ref);
132 $params .= "&archive=yes" if ($common_archive);
133 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
134 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params);
138 my $ref = shift || "";
139 my $params = "maint=" . emailfromrfc822($ref);
140 $params .= "&archive=yes" if ($common_archive);
141 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
142 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params);
147 my $params = "pkg=$ref";
148 $params .= "&archive=yes" if ($common_archive);
149 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
151 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params");
162 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
163 my $in = shift || "";
165 while ($in =~ m/[<>&"]/) {
166 $out .= $`. '&'. $saniarray{$&}. ';';
175 my $params = "bug=$ref";
176 foreach my $val (@_) {
177 $params .= "\&msg=$1" if ($val =~ /^msg=([0-9]+)/);
178 $params .= "\&archive=yes" if (!$common_archive && $val =~ /^archive.*$/);
180 $params .= "&archive=yes" if ($common_archive);
181 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
183 return $debbugs::gCGIDomain . "bugreport.cgi" . "?" . "$params";
188 return $debbugs::gCGIDomain . "package.cgi" . "?" . "package=$ref";
194 opendir(D, "$debbugs::gSpoolDir/db") or &quit("opendir db: $!");
195 @bugs = sort {$a<=>$b} grep s/\.status$//,
196 (grep m/^[0-9]+\.status$/,
208 my %displayshowpending = ("pending", "outstanding",
210 "forwarded", "forwarded to upstream software authors");
213 return "<HR><H2>No reports found!</H2></HR>\n";
216 foreach my $bug (sort {$a<=>$b} @bugs) {
217 my %status = getbugstatus($bug);
219 my @merged = sort {$a<=>$b} ($bug, split(/ /, $status{mergedwith}));
220 next unless ($common_repeatmerged || $bug == $merged[0]);
221 if (%common_include) {
223 foreach my $t (split /\s+/, $status{tags}) {
224 $okay = 1, last if (defined $common_include{$t});
226 if (defined $common_include{subj}) {
227 if (index($status{subject}, $common_include{subj}) > -1) {
233 if (%common_exclude) {
235 foreach my $t (split /\s+/, $status{tags}) {
236 $okay = 0, last if (defined $comon_exclude{$t});
238 if (defined $common_exclude{subj}) {
239 if (index($status{subject}, $common_exclude{subj}) > -1) {
246 $section{$status{pending} . "_" . $status{severity}} .=
247 sprintf "<li><a href=\"%s\">#%d: %s</a>\n<br>",
248 bugurl($bug), $bug, htmlsanit($status{subject});
249 $section{$status{pending} . "_" . $status{severity}} .=
250 htmlindexentrystatus(\%status) . "\n";
255 foreach my $pending (qw(pending forwarded done)) {
256 foreach my $severity(@debbugs::gSeverityList) {
257 $severity = $debbugs::gDefaultSeverity if ($severity eq '');
258 next unless defined $section{${pending} . "_" . ${severity}};
259 $result .= "<HR><H2>$debbugs::gSeverityDisplay{$severity} - $displayshowpending{$pending}</H2>\n";
260 $result .= "(A list of <a href=\"http://${debbugs::gWebDomain}/db/si/$pending$severity\">all such bugs</a> is available).\n";
262 $result .= $section{$pending . "_" . $severity};
263 $result .= "</UL>\n";
264 $anydone = 1 if ($pending eq "done");
268 $result .= $debbugs::gHTMLExpireNote if ($anydone);
274 if ($common_archive) {
275 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
277 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
283 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
284 my $x = $bugfunc->(pkg => $1, bug => $2, status => $4,
285 submitter => $5, severity => $6, tags => $7);
299 if (!$common_archive && defined $opt &&
300 -e "$debbugs::gSpoolDir/by-$opt.idx")
302 tie my %lookup, DB_File => "$debbugs::gSpoolDir/by-$opt.idx", O_RDONLY
303 or die "$0: can't open $debbugs::gSpoolDir/by-$opt.idx ($!)\n";
304 while ($key = shift) {
305 my $bugs = $lookup{$key};
307 push @result, (unpack 'N*', $bugs);
311 if ( $common_archive ) {
312 open I, "<$debbugs::gSpoolDir/index.archive"
313 or &quit("bugindex: $!");
315 open I, "<$debbugs::gSpoolDir/index.db"
316 or &quit("bugindex: $!");
319 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
320 if ($bugfunc->(pkg => $1, bug => $2, status => $4,
321 submitter => $5, severity => $6, tags => $7))
329 return sort {$a <=> $b} @result;
332 sub emailfromrfc822 {
334 $email =~ s/\s*\(.*\)\s*//;
335 $email = $1 if ($email =~ m/<(.*)>/);
343 while ($input =~ m/\W/) {
344 $encoded.=$`.sprintf("-%02x_",unpack("C",$&));
349 $encoded =~ s/-2e_/\./g;
350 $encoded =~ s/^([^,]+)-20_-3c_(.*)-40_(.*)-3e_/$1,$2,$3,/;
351 $encoded =~ s/^(.*)-40_(.*)-20_-28_([^,]+)-29_$/,$1,$2,$3/;
352 $encoded =~ s/-20_/_/g;
353 $encoded =~ s/-([^_]+)_-/-$1/g;
360 open(MM,"$gMaintainerFile") or &quit("open $gMaintainerFile: $!");
362 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
377 unless (open(S,"$gSpoolDir/db/$bugnum.status")) {
378 my $archdir = sprintf "%02d", $bugnum % 100;
379 open(S,"$gSpoolDir/archive/$archdir/$bugnum.status" ) or return ();
381 my @lines = qw(originator date subject msgid package tags done
382 forwarded mergedwith severity);
385 $status{shift @lines} = $_;
388 $status{shift @lines} = '' while(@lines);
390 $status{"package"} =~ s/\s*$//;
391 $status{"package"} = 'unknown' if ($status{"package"} eq '');
392 $status{"severity"} = 'normal' if ($status{"severity"} eq '');
394 $status{"pending"} = 'pending';
395 $status{"pending"} = 'forwarded' if (length($status{"forwarded"}));
396 $status{"pending"} = 'done' if (length($status{"done"}));
405 $res = "$gSpoolDir/db/$bugnum.log";
406 return $res if ( -e $res );
408 my $archdir = sprintf "%02d", $bugnum % 100;
409 $res = "$gSpoolDir/archive/$archdir/$bugnum.log";
410 return $res if ( -e $res );