Commit c9aaffd4 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 255606: Do not let buglist.cgi return all bugs by default

r/a=mkanat
parent 92cb17e0
...@@ -193,6 +193,11 @@ sub update_params { ...@@ -193,6 +193,11 @@ sub update_params {
$new_params{'ssl_redirect'} = 1; $new_params{'ssl_redirect'} = 1;
} }
# "specific_search_allow_empty_words" has been renamed to "search_allow_no_criteria".
if (exists $param->{'specific_search_allow_empty_words'}) {
$new_params{'search_allow_no_criteria'} = $param->{'specific_search_allow_empty_words'};
}
# --- DEFAULTS FOR NEW PARAMS --- # --- DEFAULTS FOR NEW PARAMS ---
_load_params unless %params; _load_params unless %params;
......
...@@ -68,7 +68,7 @@ sub get_param_list { ...@@ -68,7 +68,7 @@ sub get_param_list {
}, },
{ {
name => 'specific_search_allow_empty_words', name => 'search_allow_no_criteria',
type => 'b', type => 'b',
default => 1 default => 1
}, },
......
...@@ -1168,6 +1168,11 @@ sub _sql_where { ...@@ -1168,6 +1168,11 @@ sub _sql_where {
if ($clause_sql) { if ($clause_sql) {
$where .= "\n AND " . $clause_sql; $where .= "\n AND " . $clause_sql;
} }
elsif (!Bugzilla->params->{'search_allow_no_criteria'}
&& !$self->{allow_unlimited})
{
ThrowUserError('buglist_parameters_required');
}
return $where; return $where;
} }
......
...@@ -82,7 +82,7 @@ if (defined($searchstring)) { ...@@ -82,7 +82,7 @@ if (defined($searchstring)) {
# If configured to not allow empty words, reject empty searches from the # If configured to not allow empty words, reject empty searches from the
# Find a Specific Bug search form, including words being a single or # Find a Specific Bug search form, including words being a single or
# several consecutive whitespaces only. # several consecutive whitespaces only.
if (!Bugzilla->params->{'specific_search_allow_empty_words'} if (!Bugzilla->params->{'search_allow_no_criteria'}
&& defined($cgi->param('content')) && $cgi->param('content') =~ /^\s*$/) && defined($cgi->param('content')) && $cgi->param('content') =~ /^\s*$/)
{ {
ThrowUserError("buglist_parameters_required"); ThrowUserError("buglist_parameters_required");
......
...@@ -507,6 +507,7 @@ sub CollectSeriesData { ...@@ -507,6 +507,7 @@ sub CollectSeriesData {
eval { eval {
my $search = new Bugzilla::Search('params' => scalar $cgi->Vars, my $search = new Bugzilla::Search('params' => scalar $cgi->Vars,
'fields' => ["bug_id"], 'fields' => ["bug_id"],
'allow_unlimited' => 1,
'user' => $user); 'user' => $user);
my $sql = $search->sql; my $sql = $search->sql;
$data = $shadow_dbh->selectall_arrayref($sql); $data = $shadow_dbh->selectall_arrayref($sql);
......
...@@ -51,9 +51,14 @@ ...@@ -51,9 +51,14 @@
"access the advanced query page. It's in URL parameter " _ "access the advanced query page. It's in URL parameter " _
"format, which makes it hard to read. Sorry!", "format, which makes it hard to read. Sorry!",
specific_search_allow_empty_words => search_allow_no_criteria =>
"Whether to allow a search on the 'Simple Search' page with an empty" "Unless the code explicitly allows all $terms.bugs to be returned, this " _
_ " 'Words' field.", "parameter permits to block the execution of queries with no criteria. " _
"When turned off, a query must have some criteria specified to limit " _
"the number of $terms.bugs returned to the user. When turned on, a user " _
"is allowed to run a query with no criteria and get all $terms.bugs he can " _
"see in his list. Turning this parameter on is not recommended on large " _
"installations.",
default_search_limit => default_search_limit =>
"By default, $terms.Bugzilla limits searches done in the web" "By default, $terms.Bugzilla limits searches done in the web"
......
...@@ -920,6 +920,10 @@ ...@@ -920,6 +920,10 @@
No changes made to version <em>[% version.name FILTER html %]</em>. No changes made to version <em>[% version.name FILTER html %]</em>.
[% END %] [% END %]
[% ELSIF message_tag == "whine_query_failed" %]
The query '[% query_name FILTER html %]' from [% author.login FILTER html %]
failed: [% reason FILTER html %]
[% ELSIF message_tag == "workflow_updated" %] [% ELSIF message_tag == "workflow_updated" %]
The workflow has been updated. The workflow has been updated.
[% END %] [% END %]
......
...@@ -108,7 +108,7 @@ for "crash secure SSL flash". ...@@ -108,7 +108,7 @@ for "crash secure SSL flash".
<td></td> <td></td>
<td> <td>
[% IF Param('specific_search_allow_empty_words') %] [% IF Param('search_allow_no_criteria') %]
<input type="submit" id="search" value="Search"> <input type="submit" id="search" value="Search">
[% ELSE %] [% ELSE %]
<input type="submit" id="search" value="Search" <input type="submit" id="search" value="Search"
......
...@@ -452,7 +452,15 @@ sub run_queries { ...@@ -452,7 +452,15 @@ sub run_queries {
'params' => scalar $searchparams->Vars, 'params' => scalar $searchparams->Vars,
'user' => $args->{'recipient'}, # the search runs as the recipient 'user' => $args->{'recipient'}, # the search runs as the recipient
); );
my $sqlquery = $search->sql; # If a query fails for whatever reason, it shouldn't kill the script.
my $sqlquery = eval { $search->sql };
if ($@) {
say get_text('whine_query_failed', { query_name => $thisquery->{'name'},
author => $args->{'author'},
reason => $@ });
next;
}
$sth = $dbh->prepare($sqlquery); $sth = $dbh->prepare($sqlquery);
$sth->execute; $sth->execute;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment