]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Patch for bug 275788: Provide a line of code that defines legal query formats for...
authorjocuri%softhome.net <>
Fri, 31 Dec 2004 16:01:17 +0000 (16:01 +0000)
committerjocuri%softhome.net <>
Fri, 31 Dec 2004 16:01:17 +0000 (16:01 +0000)
Bugzilla/Search.pm
query.cgi
userprefs.cgi

index 9570a709de374e75ce5186228bc122149dc936a5..75307a0e326e38c03c72ec3574ad13e13b2aaea4 100644 (file)
@@ -32,6 +32,8 @@ use strict;
 use vars qw($userid);
 
 package Bugzilla::Search;
+use base qw(Exporter);
+@Bugzilla::Search::EXPORT = qw(IsValidQueryType);
 
 use Bugzilla::Config;
 use Bugzilla::Error;
@@ -1260,4 +1262,14 @@ sub getSQL {
     return $self->{'sql'};
 }
 
+# Define if the Query Type passed in is a valid query type that we can deal with
+sub IsValidQueryType
+{
+    my ($queryType) = @_;
+    if (grep { $_ eq $queryType } qw(specific advanced)) {
+        return 1;
+    }
+    return 0;
+}
+
 1;
index 628c731cc470fa24f4f37b24ad86b0a3b9bdc56f..4a305c1905a4da77a80b2c5a52b2f8a4d052094f 100755 (executable)
--- a/query.cgi
+++ b/query.cgi
@@ -30,6 +30,7 @@ use lib ".";
 require "CGI.pl";
 
 use Bugzilla::Constants;
+use Bugzilla::Search;
 
 use vars qw(
     @CheckOptionValues
@@ -423,7 +424,7 @@ if (!($cgi->param('query_format') || $cgi->param('format'))) {
 
 # Set cookie to current format as default, but only if the format
 # one that we should remember.
-if (grep { $_ eq $vars->{'format'} } qw(specific advanced)) {
+if (IsValidQueryType($vars->{'format'})) {
     $cgi->send_cookie(-name => 'DEFAULTFORMAT',
                       -value => $vars->{'format'},
                       -expires => "Fri, 01-Jan-2038 00:00:00 GMT");
index f8de9915d73740035d30a3680d0241ce99972526..323c87d534c457081260c9f746b0f027977e6fb0 100755 (executable)
@@ -27,6 +27,7 @@ use lib qw(.);
 
 use Bugzilla;
 use Bugzilla::Constants;
+use Bugzilla::Search;
 
 require "CGI.pl";
 
@@ -304,13 +305,18 @@ sub DoSavedSearches() {
     my @queries = @{Bugzilla->user->queries};
     my @newqueries;
     foreach my $q (@queries) {
-        if ($q->{'query'} !~ /query_format=(advanced|specific)/) {
-            if ($q->{'query'} =~ /query_format=&/) {
-                $q->{'query'} =~ s/query_format=&/query_format=advanced&/;
-            }
-            else {
-                $q->{'query'} .= '&query_format=advanced';
+        if ($q->{'query'} =~ /query_format=([^&]*)/) {
+            my $format = $1;
+            if (!IsValidQueryType($format)) {
+                if ($format eq "") {
+                    $q->{'query'} =~ s/query_format=/query_format=advanced/;
+                }
+                else {
+                    $q->{'query'} .= '&query_format=advanced';
+                }
             }
+        } else {
+            $q->{'query'} .= '&query_format=advanced';
         }
         push @newqueries, $q;
     }