Commit 62097c29 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 494369: Do not throw an error if the 'order' parameter contains invalid…

Bug 494369: Do not throw an error if the 'order' parameter contains invalid columns for buglists - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=wicked a=LpSolit
parent 35626e6e
...@@ -165,7 +165,6 @@ my $serverpush = ...@@ -165,7 +165,6 @@ my $serverpush =
|| $cgi->param('serverpush'); || $cgi->param('serverpush');
my $order = $cgi->param('order') || ""; my $order = $cgi->param('order') || "";
my $order_from_cookie = 0; # True if $order set using the LASTORDER cookie
# The params object to use for the actual query itself # The params object to use for the actual query itself
my $params; my $params;
...@@ -890,8 +889,6 @@ if (!$order || $order =~ /^reuse/i) { ...@@ -890,8 +889,6 @@ if (!$order || $order =~ /^reuse/i) {
# Cookies from early versions of Specific Search included this text, # Cookies from early versions of Specific Search included this text,
# which is now invalid. # which is now invalid.
$order =~ s/ LIMIT 200//; $order =~ s/ LIMIT 200//;
$order_from_cookie = 1;
} }
else { else {
$order = ''; # Remove possible "reuse" identifier as unnecessary $order = ''; # Remove possible "reuse" identifier as unnecessary
...@@ -920,7 +917,7 @@ if ($order) { ...@@ -920,7 +917,7 @@ if ($order) {
last ORDER; last ORDER;
}; };
do { do {
my @order; my (@order, @invalid_fragments);
my @columnnames = map($columns->{lc($_)}->{'name'}, keys(%$columns)); my @columnnames = map($columns->{lc($_)}->{'name'}, keys(%$columns));
# A custom list of columns. Make sure each column is valid. # A custom list of columns. Make sure each column is valid.
foreach my $fragment (split(/,/, $order)) { foreach my $fragment (split(/,/, $order)) {
...@@ -933,16 +930,14 @@ if ($order) { ...@@ -933,16 +930,14 @@ if ($order) {
push(@order, $fragment); push(@order, $fragment);
} }
else { else {
my $vars = { fragment => $fragment }; push(@invalid_fragments, $fragment);
if ($order_from_cookie) {
$cgi->remove_cookie('LASTORDER');
ThrowCodeError("invalid_column_name_cookie", $vars);
}
else {
ThrowCodeError("invalid_column_name_form", $vars);
}
} }
} }
if (scalar @invalid_fragments) {
$vars->{'message'} = 'invalid_column_name';
$vars->{'invalid_fragments'} = \@invalid_fragments;
}
$order = join(",", @order); $order = join(",", @order);
# Now that we have checked that all columns in the order are valid, # Now that we have checked that all columns in the order are valid,
# detaint the order string. # detaint the order string.
......
...@@ -190,17 +190,6 @@ ...@@ -190,17 +190,6 @@
The attachment number of one of the attachments you wanted to obsolete, The attachment number of one of the attachments you wanted to obsolete,
[% attach_id FILTER html %], is invalid. [% attach_id FILTER html %], is invalid.
[% ELSIF error == "invalid_column_name_cookie" %]
[% title = "Invalid Column Name" %]
The custom sort order specified in your cookie contains an invalid
column name <em>[% fragment FILTER html %]</em>.
The cookie has been cleared.
[% ELSIF error == "invalid_column_name_form" %]
[% title = "Invalid Column Name" %]
The custom sort order specified in your form submission contains an
invalid column name <em>[% fragment FILTER html %]</em>.
[% ELSIF error == "invalid_customfield_type" %] [% ELSIF error == "invalid_customfield_type" %]
[% title = "Invalid Field Type" %] [% title = "Invalid Field Type" %]
The type <em>[% type FILTER html %]</em> is not a valid field type. The type <em>[% type FILTER html %]</em> is not a valid field type.
......
...@@ -455,6 +455,11 @@ ...@@ -455,6 +455,11 @@
group. group.
[% END %] [% END %]
[% ELSIF message_tag == "invalid_column_name" %]
The custom sort order specified contains one or more invalid
column names: <em>[% invalid_fragments.join(', ') FILTER html %]</em>.
They have been removed from the sort list.
[% ELSIF message_tag == "job_queue_depth" %] [% ELSIF message_tag == "job_queue_depth" %]
[% count FILTER html %] jobs in the queue. [% count FILTER html %] jobs in the queue.
......
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