X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FCGI%2FPkgreport.pm;h=2d0de6f6c74803a704948c31e9fb7ba1961e34ce;hb=5be51c11e02e9b3ade84ff8306fdd8b5e89ab577;hp=77b55165ae669916679d04c0e7bac69854383ff7;hpb=ff74063bdaf0d398417c71e1fe8f58c916f0fb00;p=debbugs.git diff --git a/Debbugs/CGI/Pkgreport.pm b/Debbugs/CGI/Pkgreport.pm index 77b5516..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); @@ -167,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); } @@ -458,40 +459,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 = 1; - my $first_field = 1; # true if no previous fields have been - # checked - while ($el =~ /(?^|\+|,)(?[^=]+)=(?[^=,\+]+)/g) { - my ($j,$f,$v) = @+{qw(joiner field value)}; - my $isokay = 0; - $isokay = 1 if (defined $status->{$f} and $v eq $status->{$f}); - $isokay = 1 if ($f eq "tag" && defined $tags{$v}); - if (defined $j and $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;