X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FCGI%2FPkgreport.pm;h=e64300ad43cf8466ffd7614bae022ea79c98f020;hb=99e32a8e4f1a8f4fe099b76810db464c21ffd8f2;hp=4664effd027e80736bb99bc065243970c4cbce18;hpb=73337e7e6ecebf85306741ff4c1bc34c3fccc90f;p=debbugs.git diff --git a/Debbugs/CGI/Pkgreport.pm b/Debbugs/CGI/Pkgreport.pm index 4664eff..e64300a 100644 --- a/Debbugs/CGI/Pkgreport.pm +++ b/Debbugs/CGI/Pkgreport.pm @@ -28,7 +28,7 @@ None known. use warnings; use strict; use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT); -use base qw(Exporter); +use Exporter qw(import); use IO::Scalar; use Params::Validate qw(validate_with :types); @@ -41,6 +41,7 @@ use Debbugs::Bugs qw(bug_filter); use Debbugs::Packages qw(:mapping); use Debbugs::Text qw(:templates); +use Encode qw(decode_utf8); use POSIX qw(strftime); @@ -127,7 +128,7 @@ sub generate_package_info{ my @references; my $pseudodesc = getpseudodesc(); if ($package and defined($pseudodesc) and exists($pseudodesc->{$package})) { - push @references, "to the ". + push @references, "to the ". "list of other pseudo-packages"; } elsif (not defined $maint and not @{$param{bugs}}) { @@ -140,14 +141,14 @@ sub generate_package_info{ else { if ($package and defined $config{package_pages} and length $config{package_pages}) { push @references, sprintf "to the %s package page", - html_escape("http://$config{package_pages}/$package"), html_escape("$package"); + html_escape("$config{package_pages}/$package"), html_escape("$package"); } 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); + push @references, q(to the Package Tracking System); } # Only output this if the source listing is non-trivial. if ($param{binary} and $srcforpkg) { @@ -165,9 +166,9 @@ sub generate_package_info{ if (defined $maint) { print {$output} "

If you find a bug not listed here, please\n"; printf {$output} "report it.

\n", - html_escape("http://$config{web_domain}/Reporting$config{html_suffix}"); + html_escape("$config{web_domain}/Reporting$config{html_suffix}"); } - return $output_scalar; + return decode_utf8($output_scalar); } @@ -366,7 +367,6 @@ sub pkg_htmlizebugs { ); my $html = "
  • "; ##%d: %s\n
    ", - #bug_url($bug), $bug, html_escape($status{subject}); $html .= short_bug_status_html(status => \%status, options => $param{options}, ) . "\n"; @@ -458,46 +458,57 @@ sub pkg_htmlizebugs { return $result; } +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 = 0; - my $first_field = 1; # true if no previous fields have been - # checked - while ($el =~ /(?^|\+|,)(?[^=]+)=(?[^=,\+])/) { - my ($j,$f,$v) = @+{qw(joiner field value)}; - if (not defined $j) { - $j = '+'; - } - if ($j eq '+' and $first_field) { - $match = 1; - } - my $isokay = 0; - $isokay = 1 if (defined $status->{$f} and $v eq $status->{$f}); - $isokay = 1 if ($f eq "tag" && defined $tags{$v}); - if ($j eq ',') { - $match ||= $isokay; - } else { - $match &&= $isokay; - } - $first_field = 0; - } - # if there is a match, or if there were no fields to check, - # this usertag matched. - if ($match || $first_field) { - return $pos; - last; - } + if (not length $el or + parse_order_statement_into_boolean($el,$status,$tags) + ) { + return $pos; + } + $pos++; } - return $pos + 1; + return $pos; } # sets: my @names; my @prior; my @title; my @order;