]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 365082: QuickSearch using unknown field makes Bugzilla hang - Patch by Teemu...
authorlpsolit%gmail.com <>
Fri, 20 Jul 2007 17:57:47 +0000 (17:57 +0000)
committerlpsolit%gmail.com <>
Fri, 20 Jul 2007 17:57:47 +0000 (17:57 +0000)
Bugzilla/Search/Quicksearch.pm
template/en/default/global/user-error.html.tmpl

index 83746ed5f0ddd4435e3972a7c54592607297f1d4..3328e1f55932ad025dbb26e6a5de7c7ad764507f 100644 (file)
@@ -163,6 +163,7 @@ sub quicksearch {
             $#words < Bugzilla->params->{'quicksearch_comment_cutoff'};
         my @openStates = BUG_STATE_OPEN;
         my @closedStates;
+        my @unknownFields;
         my (%states, %resolutions);
 
         foreach (@$legal_statuses) {
@@ -273,8 +274,11 @@ sub quicksearch {
                         my @fields = split(/,/, $1);
                         my @values = split(/,/, $2);
                         foreach my $field (@fields) {
-                            # Be tolerant about unknown fields
-                            next unless defined(MAPPINGS->{$field});
+                            # Skip and record any unknown fields
+                            if (!defined(MAPPINGS->{$field})) {
+                                push(@unknownFields, $field);
+                                next;
+                            }
                             $field = MAPPINGS->{$field};
                             foreach (@values) {
                                 addChart($field, 'substring', $_, $negate);
@@ -376,8 +380,13 @@ sub quicksearch {
             $or = 0;
         } # foreach (@words)
 
-        # We've been very tolerant about invalid queries, so all that's left
-        # may be an empty query.
+        # Inform user about any unknown fields
+        if (scalar(@unknownFields)) {
+            ThrowUserError("quicksearch_unknown_field",
+                           { fields => \@unknownFields });
+        }
+
+        # Make sure we have some query terms left
         scalar($cgi->param())>0 || ThrowUserError("buglist_parameters_required");
     }
 
index e6871826fdfe7de08328da5aa10ab90aa7803261..21091d7cc3741a9467460d9d8ca374fdf7499a5b 100644 (file)
     [% title = "Query Name Too Long" %]
     The name of the query must be less than 64 characters long.
 
+  [% ELSIF error == "quicksearch_unknown_field" %]
+    [% title = "Unknown QuickSearch Field" %]
+    [% IF fields.unique.size == 1 %]
+      Field <code>[% fields.first FILTER html %]</code> is not a known field.
+    [% ELSE %]
+      Fields
+      [% FOREACH field = fields.unique.sort %]
+         <code>[% field FILTER html %]</code>
+         [% ', ' UNLESS loop.last() %]
+      [% END %]
+      are not known fields.
+    [% END %]
+    The legal field names are <a href="page.cgi?id=quicksearchhack.html">listed here</a>.
+
   [% ELSIF error == "reassign_to_empty" %]
     [% title = "Illegal Reassignment" %]
     To reassign [% terms.abug %], you must provide an address for