]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/CGI/Pkgreport.pm
add test for get_bug_order_index; fix faulty regex in while()
[debbugs.git] / Debbugs / CGI / Pkgreport.pm
index 8c217d7e1271c367b6e171d9776470b6540a8a2a..77b55165ae669916679d04c0e7bac69854383ff7 100644 (file)
@@ -470,20 +470,25 @@ sub get_bug_order_index {
      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;
+          my $first_field = 1; # true if no previous fields have been
+                               # checked
+          while ($el =~ /(?<joiner>^|\+|,)(?<field>[^=]+)=(?<value>[^=,\+]+)/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;
          }
      }
      return $pos + 1;