3 my $common_archive = 0;
4 my $common_repeatmerged = 1;
5 my %common_include = ();
6 my %common_exclude = ();
10 if ($opt eq "archive") { $common_archive = $val; }
11 if ($opt eq "repeatmerged") { $common_repeatmerged = $val; }
12 if ($opt eq "exclude") { %common_exclude = %{$val}; }
13 if ($opt eq "include") { %common_include = %{$val}; }
17 my ($in, $key, $val, %ret);
18 if (defined $ENV{"QUERY_STRING"} && $ENV{"QUERY_STRING"} ne "") {
19 $in=$ENV{QUERY_STRING};
20 } elsif(defined $ENV{"REQUEST_METHOD"}
21 && $ENV{"REQUEST_METHOD"} eq "POST")
23 read(STDIN,$in,$ENV{CONTENT_LENGTH});
27 foreach (split(/&/,$in)) {
29 ($key, $val) = split(/=/,$_,2);
30 $key=~s/%(..)/pack("c",hex($1))/ge;
31 $val=~s/%(..)/pack("c",hex($1))/ge;
39 print "Content-Type: text/html\n\n";
40 print "<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\n";
41 print "An error occurred. Dammit.\n";
42 print "Error was: $msg.\n";
43 print "</BODY></HTML>\n";
49 # my $Archive = $common_archive ? "archive" : "";
50 # print header . start_html("Sorry");
51 # print "Sorry bug #$msg doesn't seem to be in the $Archive database.\n";
58 my %status = getbugstatus($ref);
59 return htmlindexentrystatus(%status) if (%status);
63 sub htmlindexentrystatus {
69 if ($status{severity} eq 'normal') {
71 } elsif (grep($status{severity} eq $_, @debbugs::gStrongSeverities)) {
72 $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
74 $showseverity = "Severity: <em>$status{severity}</em>;\n";
77 $result .= "Package: <a href=\"" . pkgurl($status{"package"}) . "\">"
78 . "<strong>" . htmlsanit($status{"package"}) . "</strong></a>;\n"
79 if (length($status{"package"}));
80 $result .= $showseverity;
81 $result .= "Reported by: " . htmlsanit($status{originator});
82 $result .= ";\nTags: <strong>"
83 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
85 if (length($status{tags}));
87 my @merged= split(/ /,$status{mergedwith});
88 my $mseparator= ";\nmerged with ";
90 $result .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
94 if (length($status{done})) {
95 $result .= ";\n<strong>Done:</strong> " . htmlsanit($status{done});
96 } elsif (length($status{forwarded})) {
97 $result .= ";\n<strong>Forwarded</strong> to "
98 . htmlsanit($status{forwarded});
100 my $daysold = int((time - $status{date}) / 86400); # seconds to days
104 $font = "em" if ($daysold > 30);
105 $font = "strong" if ($daysold > 60);
106 $efont = "</$font>" if ($font);
107 $font = "<$font>" if ($font);
109 my $yearsold = int($daysold / 364);
110 $daysold = $daysold - $yearsold * 364;
112 $result .= ";\n $font";
113 $result .= "1 year and " if ($yearsold == 1);
114 $result .= "$yearsold years and " if ($yearsold > 1);
115 $result .= "1 day old" if ($daysold == 1);
116 $result .= "$daysold days old" if ($daysold != 1);
127 my $ref = shift || "";
128 my $params = "submitter=" . emailfromrfc822($ref);
129 $params .= "&archive=yes" if ($common_archive);
130 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
131 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params);
135 my $ref = shift || "";
136 my $params = "maint=" . emailfromrfc822($ref);
137 $params .= "&archive=yes" if ($common_archive);
138 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
139 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params);
144 my $params = "pkg=$ref";
145 $params .= "&archive=yes" if ($common_archive);
146 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
148 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params");
159 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
160 my $in = shift || "";
162 while ($in =~ m/[<>&"]/) {
163 $out .= $`. '&'. $saniarray{$&}. ';';
172 my $params = "bug=$ref";
173 foreach my $val (@_) {
174 $params .= "\&msg=$1" if ($val =~ /^msg=([0-9]+)/);
175 $params .= "\&archive=yes" if (!$common_archive && $val =~ /^archive.*$/);
177 $params .= "&archive=yes" if ($common_archive);
178 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
180 return $debbugs::gCGIDomain . "bugreport.cgi" . "?" . "$params";
185 return $debbugs::gCGIDomain . "package.cgi" . "?" . "package=$ref";
191 opendir(D, "$debbugs::gSpoolDir/db") or &quit("opendir db: $!");
192 @bugs = sort {$a<=>$b} grep s/\.status$//,
193 (grep m/^[0-9]+\.status$/,
205 my %displayshowpending = ("pending", "outstanding",
207 "forwarded", "forwarded to upstream software authors");
210 return "<HR><H2>No reports found!</H2></HR>\n";
213 foreach my $bug (sort {$a<=>$b} @bugs) {
214 my %status = getbugstatus($bug);
216 my @merged = sort {$a<=>$b} ($bug, split(/ /, $status{mergedwith}));
217 next unless ($common_repeatmerged || $bug == $merged[0]);
218 if (%common_include) {
220 foreach my $t (split /\s+/, $status{tags}) {
221 $okay = 1, last if (defined $common_include{$t});
225 if (%common_exclude) {
227 foreach my $t (split /\s+/, $status{tags}) {
228 $okay = 0, last if (defined $comon_exclude{$t});
233 $section{$status{pending} . "_" . $status{severity}} .=
234 sprintf "<li><a href=\"%s\">#%d: %s</a>\n<br>",
235 bugurl($bug), $bug, htmlsanit($status{subject});
236 $section{$status{pending} . "_" . $status{severity}} .=
237 htmlindexentrystatus(\%status) . "\n";
242 foreach my $pending (qw(pending forwarded done)) {
243 foreach my $severity(@debbugs::gSeverityList) {
244 $severity = $debbugs::gDefaultSeverity if ($severity eq '');
245 next unless defined $section{${pending} . "_" . ${severity}};
246 $result .= "<HR><H2>$debbugs::gSeverityDisplay{$severity} - $displayshowpending{$pending}</H2>\n";
247 $result .= "(A list of <a href=\"http://www.debian.org/Bugs/db/si/$pending$severity\">all such bugs</a> is available).\n";
249 $result .= $section{$pending . "_" . $severity};
250 $result .= "</UL>\n";
251 $anydone = 1 if ($pending eq "done");
255 $result .= $debbugs::gHTMLExpireNote if ($anydone);
260 my $submitter = shift;
263 ($subemail = $d{"submitter"}) =~ s/\s*\(.*\)\s*//;
264 if ($subemail =~ m/<(.*)>/) { $subemail = $1 }
265 return $subemail eq $submitter;
267 return getbugs($chk);
272 my $severity = shift;
275 return ($d{"severity"} eq $severity) && ($d{"status"} eq $status);
277 return getbugs($chk);
282 my %maintainers = getmaintainers();
285 ($maintemail = $maintainers{$d{"pkg"}} || "") =~ s/\s*\(.*\)\s*//;
286 if ($maintemail =~ m/<(.*)>/) { $maintemail = $1 }
287 return $maintemail eq $maint;
289 return getbugs($chk);
293 my $maintenc = shift;
294 my %maintainers = getmaintainers();
295 return getbugs(sub {my %d=@_; return maintencoded($maintainers{$d{"pkg"}} || "") eq $maintenc});
300 return getbugs( sub { my %d = @_; return $inpkg eq $d{"pkg"} });
305 if ($common_archive) {
306 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
308 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
314 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
315 my $x = $bugfunc->(pkg => $1, bug => $2, status => $4,
316 submitter => $5, severity => $6, tags => $7);
327 if ( $common_archive ) {
328 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
330 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
336 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
337 if ($bugfunc->(pkg => $1, bug => $2, status => $4, submitter => $5,
338 severity => $6, tags => $7))
341 #last if (@result > 400);
346 return sort {$a <=> $b} @result;
351 if ( $common_archive ) {
352 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
354 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
357 $descstr{ $1 } = 1 if (m/^(\S+)/);
363 sub emailfromrfc822 {
365 $email =~ s/\s*\(.*\)\s*//;
366 $email = $1 if ($email =~ m/<(.*)>/);
374 while ($input =~ m/\W/) {
375 $encoded.=$`.sprintf("-%02x_",unpack("C",$&));
380 $encoded =~ s/-2e_/\./g;
381 $encoded =~ s/^([^,]+)-20_-3c_(.*)-40_(.*)-3e_/$1,$2,$3,/;
382 $encoded =~ s/^(.*)-40_(.*)-20_-28_([^,]+)-29_$/,$1,$2,$3/;
383 $encoded =~ s/-20_/_/g;
384 $encoded =~ s/-([^_]+)_-/-$1/g;
391 open(MM,"$gMaintainerFile") or &quit("open $gMaintainerFile: $!");
393 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
408 unless (open(S,"$gSpoolDir/db/$bugnum.status")) {
409 my $archdir = sprintf "%02d", $bugnum % 100;
410 open(S,"$gSpoolDir/archive/$archdir/$bugnum.status" ) or return ();
412 my @lines = qw(originator date subject msgid package tags done
413 forwarded mergedwith severity);
416 $status{shift @lines} = $_;
419 $status{shift @lines} = '' while(@lines);
421 $status{"package"} =~ s/\s*$//;
422 $status{"package"} = 'unknown' if ($status{"package"} eq '');
423 $status{"severity"} = 'normal' if ($status{"severity"} eq '');
425 $status{"pending"} = 'pending';
426 $status{"pending"} = 'forwarded' if (length($status{"forwarded"}));
427 $status{"pending"} = 'done' if (length($status{"done"}));
436 $res = "$gSpoolDir/db/$bugnum.log";
437 return $res if ( -e $res );
439 my $archdir = sprintf "%02d", $bugnum % 100;
440 $res = "$gSpoolDir/archive/$archdir/$bugnum.log";
441 return $res if ( -e $res );