From 708b6cd93e59b2aba050f9c575fe118e6ffa53dc Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" Date: Fri, 20 Jul 2007 12:57:47 +0000 Subject: [PATCH] Bug 365082: QuickSearch using unknown field makes Bugzilla hang - Patch by Teemu Mannermaa r/a=LpSolit git-svn-id: svn://10.0.0.236/trunk@230362 18797224-902f-48f8-a5cc-f745e15eee43 --- .../bugzilla/Bugzilla/Search/Quicksearch.pm | 17 +++++++++++++---- .../en/default/global/user-error.html.tmpl | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bugzilla/Search/Quicksearch.pm b/mozilla/webtools/bugzilla/Bugzilla/Search/Quicksearch.pm index e8664005cbd..884479e50a8 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Search/Quicksearch.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Search/Quicksearch.pm @@ -170,6 +170,7 @@ sub quicksearch { $#words < Bugzilla->params->{'quicksearch_comment_cutoff'}; my @openStates = BUG_STATE_OPEN; my @closedStates; + my @unknownFields; my (%states, %resolutions); foreach (@$legal_statuses) { @@ -286,8 +287,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); @@ -392,8 +396,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"); } diff --git a/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl b/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl index 072a10a5673..65853276637 100644 --- a/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl +++ b/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl @@ -1295,6 +1295,20 @@ [% 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 [% fields.first FILTER html %] is not a known field. + [% ELSE %] + Fields + [% FOREACH field = fields.unique.sort %] + [% field FILTER html %] + [% ', ' UNLESS loop.last() %] + [% END %] + are not known fields. + [% END %] + The legal field names are listed here. + [% ELSIF error == "reassign_to_empty" %] [% title = "Illegal Reassignment" %] To reassign [% terms.abug %], you must provide an address for