X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FCGI%2FPkgreport.pm;h=2d0de6f6c74803a704948c31e9fb7ba1961e34ce;hb=5be51c11e02e9b3ade84ff8306fdd8b5e89ab577;hp=84663ed8fcc27b17aa0562282c5d734b69eef730;hpb=dce5d2b3d3dde9b639ccba7224da3100ba803e78;p=debbugs.git diff --git a/Debbugs/CGI/Pkgreport.pm b/Debbugs/CGI/Pkgreport.pm index 84663ed..2d0de6f 100644 --- a/Debbugs/CGI/Pkgreport.pm +++ b/Debbugs/CGI/Pkgreport.pm @@ -41,6 +41,7 @@ use Debbugs::Bugs qw(bug_filter); use Debbugs::Packages qw(:mapping); use Debbugs::Text qw(:templates); +use Encode qw(encode_utf8); use POSIX qw(strftime); @@ -51,13 +52,9 @@ BEGIN{ @EXPORT = (); %EXPORT_TAGS = (html => [qw(short_bug_status_html pkg_htmlizebugs), - qw(pkg_javascript), - qw(pkg_htmlselectyesno pkg_htmlselectsuite), - qw(buglinklist pkg_htmlselectarch) ], - misc => [qw(generate_package_info make_order_list), - qw(myurl), - qw(get_bug_order_index determine_ordering), + misc => [qw(generate_package_info), + qw(determine_ordering), ], ); @EXPORT_OK = (qw()); @@ -78,7 +75,7 @@ sub generate_package_info{ spec => {binary => {type => BOOLEAN, default => 1, }, - package => {type => SCALAR|ARRAYREF, + package => {type => SCALAR,#|ARRAYREF, }, options => {type => HASHREF, }, @@ -111,7 +108,8 @@ sub generate_package_info{ } else { print {$output} "

There is no maintainer for $showpkg. ". - "Please do not report new bugs against this package.

\n"; + "This means that this package no longer exists (or never existed). ". + "Please do not report new bugs against this package.

\n"; } my @pkgs = getsrcpkgs($srcforpkg); @pkgs = grep( !/^\Q$package\E$/, @pkgs ); @@ -134,9 +132,11 @@ sub generate_package_info{ "list of other pseudo-packages"; } elsif (not defined $maint and not @{$param{bugs}}) { - print {$output} "

There is no record of the " . html_escape($package) . - ($param{binary} ? " package" : " source package") . - ", and no bugs have been filed against it.

"; + # don't bother printing out this information, because it's + # already present above. + # print {$output} "

There is no record of the " . html_escape($package) . + # ($param{binary} ? " package" : " source package") . + # ", and no bugs have been filed against it.

"; } else { if ($package and defined $config{package_pages} and length $config{package_pages}) { @@ -146,6 +146,8 @@ sub generate_package_info{ if (defined $config{subscription_domain} and length $config{subscription_domain}) { my $ptslink = $param{binary} ? $srcforpkg : $package; + # the pts only wants the source, and doesn't care about src: (#566089) + $ptslink =~ s/^src://; push @references, q(to the Package Tracking System); } # Only output this if the source listing is non-trivial. @@ -166,7 +168,7 @@ sub generate_package_info{ printf {$output} "report it.

\n", html_escape("http://$config{web_domain}/Reporting$config{html_suffix}"); } - return $output_scalar; + return encode_utf8($output_scalar); } @@ -223,7 +225,7 @@ sub short_bug_status_html { if (@blockedby && $status{"pending"} ne 'fixed' && ! length($status{done})) { for my $b (@blockedby) { my %s = %{get_bug_status($b)}; - next if $s{"pending"} eq 'fixed' || length $s{done}; + next if (defined $s{pending} and $s{pending} eq 'fixed') or (defined $s{done} and length $s{done}); push @{$status{blockedby_array}},{bug_num => $b, subject => $s{subject}, status => \%s}; } } @@ -233,7 +235,7 @@ sub short_bug_status_html { if (@blocks && $status{"pending"} ne 'fixed' && ! length($status{done})) { for my $b (@blocks) { my %s = %{get_bug_status($b)}; - next if $s{"pending"} eq 'fixed' || length $s{done}; + next if (defined $s{pending} and $s{pending} eq 'fixed') or (defined $s{done} and length $s{done}); push @{$status{blocks_array}}, {bug_num => $b, subject => $s{subject}, status => \%s}; } } @@ -457,112 +459,59 @@ sub pkg_htmlizebugs { return $result; } -sub pkg_javascript { - return fill_in_template(template=>'cgi/pkgreport_javascript', - ); -} - -sub pkg_htmlselectyesno { - my ($name, $n, $y, $default) = @_; - return sprintf('', $name, ($default ? "" : " selected"), $n, ($default ? " selected" : ""), $y); -} - -sub pkg_htmlselectsuite { - my $id = sprintf "b_%d_%d_%d", $_[0], $_[1], $_[2]; - my @suites = ("stable", "testing", "unstable", "experimental"); - my %suiteaka = ("stable", "etch", "testing", "lenny", "unstable", "sid"); - my $defaultsuite = "unstable"; - - my $result = sprintf ''; - return $result; -} - -sub pkg_htmlselectarch { - my $id = sprintf "b_%d_%d_%d", $_[0], $_[1], $_[2]; - my @arches = qw(alpha amd64 arm hppa i386 ia64 m68k mips mipsel powerpc s390 sparc); - - my $result = sprintf ''; - return $result; -} - -sub myurl { - my %param = @_; - return html_escape(pkg_url(map {exists $param{$_}?($_,$param{$_}):()} - qw(archive repeatmerged mindays maxdays), - qw(version dist arch package src tag maint submitter) - ) - ); -} - -sub make_order_list { - my $vfull = shift; - my @x = (); - - if ($vfull =~ m/^([^:]+):(.*)$/) { - my $v = $1; - for my $vv (split /,/, $2) { - push @x, "$v=$vv"; - } - } - else { - for my $v (split /,/, $vfull) { - next unless $v =~ m/.=./; - push @x, $v; - } - } - push @x, ""; # catch all - return @x; +sub parse_order_statement_into_boolean { + my ($statement,$status,$tags) = @_; + + if (not defined $tags) { + $tags = {map { $_, 1 } split / /, $status->{"tags"} + } + if defined $status->{"tags"}; + + } + # replace all + with && + $statement =~ s/\+/&&/g; + # replace all , with || + $statement =~ s/,/||/g; + $statement =~ s{([^\&\|\=]+) # field + = + ([^\&\|\=]+) # value + }{ + my $ok = 0; + if ($1 eq 'tag') { + $ok = 1 if defined $tags->{$2}; + } else { + $ok = 1 if defined $status->{$1} and + $status->{$1} eq $2; + } + $ok; + }exg; + # check that the parsed statement is just valid boolean statements + if ($statement =~ /^([01\(\)\&\|]+)$/) { + return eval "$1"; + } else { + # this is an invalid boolean statement + return 0; + } } sub get_bug_order_index { my $order = shift; my $status = shift; - my $pos = -1; - - my %tags = (); - %tags = map { $_, 1 } split / /, $status->{"tags"} - if defined $status->{"tags"}; - + my $pos = 0; + my $tags = {map { $_, 1 } split / /, $status->{"tags"} + } + if defined $status->{"tags"}; for my $el (@${order}) { - $pos++; - my $match = 1; - for my $item (split /[+]/, $el) { - my ($f, $v) = split /=/, $item, 2; - next unless (defined $f and defined $v); - my $isokay = 0; - $isokay = 1 if (defined $status->{$f} and $v eq $status->{$f}); - $isokay = 1 if ($f eq "tag" && defined $tags{$v}); - unless ($isokay) { - $match = 0; - last; - } - } - if ($match) { - return $pos; - last; - } + if (not length $el or + parse_order_statement_into_boolean($el,$status,$tags) + ) { + return $pos; + } + $pos++; } - return $pos + 1; + return $pos; } -sub buglinklist { - my ($prefix, $infix, @els) = @_; - return '' if not @els; - return $prefix . bug_linklist($infix,'submitter',@els); -} - - # sets: my @names; my @prior; my @title; my @order; sub determine_ordering {