X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=cgi%2Fpkgreport.cgi;h=455df20cea2896c7f2645c601d59a14584ce50a4;hb=1a1fa6f0af2be9d4076d9aad5f5a84c5fb3d9a8a;hp=3750949728c8dbbe38672d0d25d89445743383e1;hpb=46fa42780ecb746d7bec2fb01190b05584b9283e;p=debbugs.git diff --git a/cgi/pkgreport.cgi b/cgi/pkgreport.cgi index 3750949..455df20 100755 --- a/cgi/pkgreport.cgi +++ b/cgi/pkgreport.cgi @@ -13,6 +13,12 @@ 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); @@ -24,6 +30,8 @@ use Debbugs::Common qw(getparsedaddrs make_list getmaintainers getpseudodesc); use Debbugs::Bugs qw(get_bugs bug_filter newest_bug); use Debbugs::Packages qw(getsrcpkgs getpkgsrc get_versions); +use Debbugs::Status qw(splitpackages); + use Debbugs::CGI qw(:all); use Debbugs::CGI::Pkgreport qw(:all); @@ -52,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, ); @@ -75,12 +84,33 @@ 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}; + $param{$key} = [map {split /\s*,\s*/} make_list($param{$key})]; + } + # kill off keys for which empty values are meaningless + for my $key (qw(package src submitter affects severity status dist)) { + next unless exists $param{$key}; + $param{$key} = [grep {defined $_ and length $_} + make_list($param{$key})]; } print $q->redirect(munge_url('pkgreport.cgi?',%param)); 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}){ @@ -100,6 +130,10 @@ elsif (lc($param{archive}) eq 'yes') { $param{archive} = 1; } +# fixup dist +if (exists $param{dist} and $param{dist} eq '') { + delete $param{dist}; +} my $include = $param{'&include'} || $param{'include'} || ""; my $exclude = $param{'&exclude'} || $param{'exclude'} || ""; @@ -161,8 +195,7 @@ for my $incexcmap (@inc_exc_mapping) { my $maxdays = ($param{'maxdays'} || -1); my $mindays = ($param{'mindays'} || 0); my $version = $param{'version'} || undef; -# XXX Once the options/selection is rewritten, this should go away -my $dist = $param{dist} || undef; + our %hidden = map { $_, 1 } qw(status severity classification); our %cats = ( @@ -211,21 +244,22 @@ if (defined $param{maintenc}) { delete $param{maintenc} } +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})]; } -if (exists $param{pkg}) { - $param{package} = $param{pkg}; - delete $param{pkg}; -} +my %bugusertags; +my %ut; +my %seen_users; -our %bugusertags; -our %ut; for my $user (map {split /[\s*,\s*]+/} make_list($param{users}||[])) { next unless length($user); - add_user($user); + add_user($user,\%ut,\%bugusertags,\%seen_users,\%cats,\%hidden); } if (defined $param{usertag}) { @@ -236,12 +270,13 @@ if (defined $param{usertag}) { unless (defined $t && $t ne "") { $t = join(",", keys(%select_ut)); } - add_user($u); + add_user($u,\%ut,\%bugusertags,\%seen_users,\%cats,\%hidden); push @{$param{tag}}, split /,/, $t; } } -quitcgi("You have to choose something to select by") unless grep {exists $param{$_}} keys %package_search_keys; +quitcgi("You have to choose something to select by", '400 Bad Request') + unless grep {exists $param{$_}} keys %package_search_keys; my $Archived = $param{archive} ? " Archived" : ""; @@ -253,42 +288,6 @@ my $this = munge_url('pkgreport.cgi?', my %indexentry; my %strings = (); -my $dtime = strftime "%a, %e %b %Y %T UTC", gmtime; -my $tail_html = $gHTMLTail; -$tail_html = $gHTMLTail; -$tail_html =~ s/SUBSTITUTE_DTIME/$dtime/; - -our %seen_users; -sub add_user { - my $ut = \%ut; - my $u = shift; - - return if $seen_users{$u}; - $seen_users{$u} = 1; - - my $user = Debbugs::User::get_user($u); - - my %vis = map { $_, 1 } @{$user->{"visible_cats"}}; - for my $c (keys %{$user->{"categories"}}) { - $cats{$c} = $user->{"categories"}->{$c}; - $hidden{$c} = 1 unless defined $vis{$c}; - } - - for my $t (keys %{$user->{"tags"}}) { - $ut->{$t} = [] unless defined $ut->{$t}; - push @{$ut->{$t}}, @{$user->{"tags"}->{$t}}; - } - - %bugusertags = (); - for my $t (keys %{$ut}) { - for my $b (@{$ut->{$t}}) { - $bugusertags{$b} = [] unless defined $bugusertags{$b}; - push @{$bugusertags{$b}}, $t; - } - } -# set_option("bugusertags", \%bugusertags); -} - my @bugs; # addusers for source and binary packages being searched for @@ -308,7 +307,8 @@ for my $package (# For binary packages, add the binary package ), ) { next unless defined $package; - add_user($package.'@'.$config{usertag_package_domain}) + add_user($package.'@'.$config{usertag_package_domain}, + \%ut,\%bugusertags,\%seen_users,\%cats,\%hidden) if defined $config{usertag_package_domain}; } @@ -324,8 +324,9 @@ my @temp = @package_search_key_order; while (my ($key,$value) = splice @temp, 0, 2) { next unless exists $param{$key}; my @entries = (); - $param{$key} = [map {split /\s*,\s*/} make_list($param{$key})]; for my $entry (make_list($param{$key})) { + # we'll handle newest below + next if $key eq 'newest'; my $extra = ''; if (exists $param{dist} and ($key eq 'package' or $key eq 'src')) { my %versions = get_versions(package => $entry, @@ -350,39 +351,51 @@ while (my ($key,$value) = splice @temp, 0, 2) { } $extra= " ($verdesc)" if keys %versions; } - push @entries, $entry.$extra; + if ($key eq 'maint' and $entry eq '') { + push @entries, "no one (packages without maintainers)" + } + else { + push @entries, $entry.$extra; + } } - push @title,$value.' '.join(' or ', @entries); -} -my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title); -@title = (); - -# we have to special case the maint="" search, unfortunatly. -if (defined $param{maint} and $param{maint} eq "" or ref($param{maint}) and not @{$param{maint}}) { - my %maintainers = %{getmaintainers()}; - @bugs = get_bugs(function => - sub {my %d=@_; - foreach my $try (splitpackages($d{"pkg"})) { - return 1 if not exists $maintainers{$try}; - } - return 0; - } - ); - $title = $gBugs.' in packages with no maintainer'; + push @title,$value.' '.join(' or ', @entries) if @entries; } -elsif (defined $param{newest}) { +if (defined $param{newest}) { my $newest_bug = newest_bug(); @bugs = ($newest_bug - $param{newest} + 1) .. $newest_bug; - $title = @bugs.' newest '.$gBugs; + push @title, 'in '.@bugs.' newest reports'; + $param{bugs} = [exists $param{bugs}?make_list($param{bugs}):(), + @bugs, + ]; } -else { - #yeah for magick! - @bugs = get_bugs((map {exists $param{$_}?($_,$param{$_}):()} - keys %package_search_keys, 'archive'), - usertags => \%ut, - ); + +my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title); +@title = (); + +#yeah for magick! +@bugs = get_bugs((map {exists $param{$_}?($_,$param{$_}):()} + grep {$_ ne 'newest'} + keys %package_search_keys, 'archive'), + 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 + + if (defined $param{version}) { $title .= " at version $param{version}"; } @@ -421,8 +434,10 @@ my $result = pkg_htmlizebugs(bugs => \@bugs, exclude => $exclude, this => $this, options => \%param, + (exists $param{dist})?(dist => $param{dist}):(), ); +print "Cache-Control: public, max-age=300\n"; print "Content-Type: text/html; charset=utf-8\n\n"; print "\n"; @@ -432,6 +447,7 @@ print "
\n" . "\n" . '' . "\n"; +print qq(\n); print "See the '.join (' or ',@archive_links)."
\n"; - print $result; -print pkg_javascript() . "\n"; +print fill_in_template(template=>'cgi/pkgreport_javascript'); print qq($tail_html"; - +print fill_in_template(template=>'html/html_tail', + hole_var => {'&strftime' => \&POSIX::strftime, + }, + ); print "\n";