]> git.donarmstrong.com Git - debbugs.git/blobdiff - cgi/pkgreport.cgi
skip duplicate bugs in get_status_and_filter
[debbugs.git] / cgi / pkgreport.cgi
index f8eb6a44aecb0091f54120f037f850826c8ded95..859c8edd4226d7a3e1c4acf0abf5e2e4edc42dcb 100755 (executable)
 use warnings;
 use strict;
 
+# Sanitize environent for taint
+BEGIN{
+    delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
+}
+
+binmode(STDOUT,':encoding(UTF-8)');
 use POSIX qw(strftime nice);
 
 use Debbugs::Config qw(:globals :text :config);
@@ -54,6 +60,7 @@ our %param = cgi_parameters(query => $q,
                                       qw(bug-rev pend-rev sev-rev),
                                       qw(maxdays mindays version),
                                       qw(data which dist newest),
+                                      qw(noaffects),
                                      ],
                            default => $default_params,
                           );
@@ -77,7 +84,8 @@ if (exists $param{form_options} and defined $param{form_options}) {
      }
      for my $incexc (qw(include exclude)) {
          next unless exists $param{$incexc};
-         $param{$incexc} = [grep /\S\:\S/, make_list($param{$incexc})];
+         # normalize tag to tags
+         $param{$incexc} = [map {s/^tag:/tags:/; $_} grep /\S\:\S/, make_list($param{$incexc})];
      }
      for my $key (keys %package_search_keys) {
          next unless exists $param{key};
@@ -93,6 +101,16 @@ if (exists $param{form_options} and defined $param{form_options}) {
      exit 0;
 }
 
+# normalize innclude/exclude keys; currently this is in two locations,
+# which is suboptimal. Closes: #567407
+for my $incexc (qw(include exclude)) {
+    next unless exists $param{$incexc};
+    # normalize tag to tags
+    $param{$incexc} = [map {s/^tag:/tags:/; $_} make_list($param{$incexc})];
+}
+
+
+
 # map from yes|no to 1|0
 for my $key (qw(repeatmerged bug-rev pend-rev sev-rev)) {
      if (exists $param{$key}){
@@ -199,7 +217,7 @@ our %cats = (
     } ],
     "classification" => [ {
         "nam" => "Classification",
-        "pri" => [qw(pending=pending+tag=wontfix 
+        "pri" => [qw(pending=pending+tag=wontfix
                      pending=pending+tag=moreinfo
                      pending=pending+tag=patch
                      pending=pending+tag=confirmed
@@ -226,16 +244,15 @@ if (defined $param{maintenc}) {
      delete $param{maintenc}
 }
 
-
-if (not grep {exists $param{$_}} keys %package_search_keys and exists $param{users}) {
-     $param{usertag} = [make_list($param{users})];
-}
-
 if (exists $param{pkg}) {
      $param{package} = $param{pkg};
      delete $param{pkg};
 }
 
+if (not grep {exists $param{$_}} keys %package_search_keys and exists $param{users}) {
+     $param{usertag} = [make_list($param{users})];
+}
+
 my %bugusertags;
 my %ut;
 my %seen_users;
@@ -361,6 +378,30 @@ my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title);
                 usertags => \%ut,
                );
 
+# shove in bugs which affect this package if there is a package or a
+# source given (by default), but no affects options given
+if (not exists $param{affects} and not exists $param{noaffects} and
+    (exists $param{src} or
+     exists $param{package})) {
+    push @bugs, get_bugs((map {my $key = $_;
+                              exists $param{$key}?($key =~ /^(?:package|src)$/?'affects':$key,
+                                                 ($key eq 'src'?[map {"src:$_"}make_list($param{$key})]:$param{$_})):()}
+                         grep {$_ ne 'newest'}
+                         keys %package_search_keys, 'archive'),
+                        usertags => \%ut,
+                       );
+}
+
+# filter out included or excluded bugs
+my $bug_status =
+    get_status_and_filter(bugs => \@bugs,
+                          bugusertags => \%bugusertags,
+                          repeatmerged => $param{repeatmerged},
+                          include => $include,
+                          exclude => $exclude,
+                          (exists $param{dist})?(dist    => $param{dist}):(),);
+@bugs = keys %{$bug_status};
+
 if (defined $param{version}) {
      $title .= " at version $param{version}";
 }
@@ -370,7 +411,10 @@ elsif (defined $param{dist}) {
 
 $title = html_escape($title);
 
-my @names; my @prior; my @order;
+my @names;
+# @prior contains the priority of the categories; numbers closer to
+# zero are shown nearer the top
+my @prior; my @order;
 determine_ordering(cats => \%cats,
                   param => \%param,
                   ordering => \$ordering,
@@ -380,27 +424,19 @@ determine_ordering(cats => \%cats,
                   order => \@order,
                  );
 
-# strip out duplicate bugs
-my %bugs;
-@bugs{@bugs} = @bugs;
-@bugs = keys %bugs;
-
 my $result = pkg_htmlizebugs(bugs => \@bugs,
-                            names => \@names,
-                            title => \@title,
-                            order => \@order,
-                            prior => \@prior,
-                            ordering => $ordering,
-                            bugusertags => \%bugusertags,
-                            bug_rev => $bug_rev,
-                            bug_order => $bug_order,
-                            repeatmerged => $param{repeatmerged},
-                            include => $include,
-                            exclude => $exclude,
-                            this => $this,
-                            options => \%param,
-                            (exists $param{dist})?(dist    => $param{dist}):(),
-                           );
+                             bug_status => $bug_status,
+                             names => \@names,
+                             title => \@title,
+                             order => \@order,
+                             prior => \@prior,
+                             ordering => $ordering,
+                             bugusertags => \%bugusertags,
+                             bug_rev => $bug_rev,
+                             bug_order => $bug_order,
+                             options => \%param,
+                             (exists $param{dist})?(dist    => $param{dist}):(),
+                            );
 
 print "Content-Type: text/html; charset=utf-8\n\n";
 
@@ -417,15 +453,15 @@ print "<H1>" . "$gProject$Archived $gBug report logs: $title" .
 
 my $showresult = 1;
 
-my $pkg = $param{package} if defined $param{package};
-my $src = $param{src} if defined $param{src};
+my ($pkg) = make_list($param{package}) if defined $param{package};
+my ($src) = make_list($param{src}) if defined $param{src};
 
 my $pseudodesc = getpseudodesc();
 if (defined $pseudodesc and defined $pkg and exists $pseudodesc->{$pkg}) {
      delete $param{dist};
 }
 
-# output infomration about the packages
+# output information about the packages
 
 for my $package (make_list($param{package}||[])) {
      print generate_package_info(binary => 1,
@@ -455,7 +491,7 @@ if (exists $param{submitter}) {
 
 print $result;
 
-print pkg_javascript() . "\n";
+print fill_in_template(template=>'cgi/pkgreport_javascript');
 
 print qq(<h2 class="outstanding"><!--<a class="options" href="javascript:toggle(1)">-->Options<!--</a>--></h2>\n);