Commit 54fc8285 authored by gerv%gerv.net's avatar gerv%gerv.net

Bug 191020 - buglist.cgi doesn't always get query names right for filename to…

Bug 191020 - buglist.cgi doesn't always get query names right for filename to save. Patch by gerv; r=bbaetz, a=justdave.
parent 85bb266e
...@@ -141,22 +141,6 @@ if ($::buffer =~ /&cmd-/) { ...@@ -141,22 +141,6 @@ if ($::buffer =~ /&cmd-/) {
exit; exit;
} }
# Generate a reasonable filename for the user agent to suggest to the user
# when the user saves the bug list. Uses the name of the remembered query
# if available. We have to do this now, even though we return HTTP headers
# at the end, because the fact that there is a remembered query gets
# forgotten in the process of retrieving it.
my @time = localtime(time());
my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3];
my $filename = "bugs-$date.$format->{extension}";
$::FORM{'cmdtype'} ||= "";
if ($::FORM{'cmdtype'} eq 'runnamed') {
$filename = "$::FORM{'namedcmd'}-$date.$format->{extension}";
# Remove white-space from the filename so the user cannot tamper
# with the HTTP headers.
$filename =~ s/\s//;
}
################################################################################ ################################################################################
# Utilities # Utilities
################################################################################ ################################################################################
...@@ -188,6 +172,18 @@ sub LookupNamedQuery { ...@@ -188,6 +172,18 @@ sub LookupNamedQuery {
return $result; return $result;
} }
sub LookupSeries {
my ($series_id) = @_;
detaint_natural($series_id) || ThrowCodeError("invalid_series_id");
my $dbh = Bugzilla->instance->dbh;
my $result = $dbh->selectrow_array("SELECT query FROM series " .
"WHERE series_id = $series_id");
$result
|| ThrowCodeError("invalid_series_id", {'series_id' => $series_id});
return $result;
}
sub GetQuip { sub GetQuip {
my $quip; my $quip;
...@@ -231,6 +227,9 @@ sub GetGroupsByUserId { ...@@ -231,6 +227,9 @@ sub GetGroupsByUserId {
# Command Execution # Command Execution
################################################################################ ################################################################################
$::FORM{'cmdtype'} ||= "";
$::FORM{'remaction'} ||= "";
# Backwards-compatibility - the old interface had cmdtype="runnamed" to run # Backwards-compatibility - the old interface had cmdtype="runnamed" to run
# a named command, and we can't break this because it's in bookmarks. # a named command, and we can't break this because it's in bookmarks.
if ($::FORM{'cmdtype'} eq "runnamed") { if ($::FORM{'cmdtype'} eq "runnamed") {
...@@ -245,6 +244,21 @@ if ($::FORM{'cmdtype'} eq "runnamed") { ...@@ -245,6 +244,21 @@ if ($::FORM{'cmdtype'} eq "runnamed") {
# This will be modified, so make a copy. # This will be modified, so make a copy.
$params ||= new Bugzilla::CGI($cgi); $params ||= new Bugzilla::CGI($cgi);
# Generate a reasonable filename for the user agent to suggest to the user
# when the user saves the bug list. Uses the name of the remembered query
# if available. We have to do this now, even though we return HTTP headers
# at the end, because the fact that there is a remembered query gets
# forgotten in the process of retrieving it.
my @time = localtime(time());
my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3];
my $filename = "bugs-$date.$format->{extension}";
if ($::FORM{'cmdtype'} eq "dorem" && $::FORM{'remaction'} =~ /^run/) {
$filename = "$::FORM{'namedcmd'}-$date.$format->{extension}";
# Remove white-space from the filename so the user cannot tamper
# with the HTTP headers.
$filename =~ s/\s/_/g;
}
# Take appropriate action based on user's request. # Take appropriate action based on user's request.
if ($::FORM{'cmdtype'} eq "dorem") { if ($::FORM{'cmdtype'} eq "dorem") {
if ($::FORM{'remaction'} eq "run") { if ($::FORM{'remaction'} eq "run") {
...@@ -253,6 +267,12 @@ if ($::FORM{'cmdtype'} eq "dorem") { ...@@ -253,6 +267,12 @@ if ($::FORM{'cmdtype'} eq "dorem") {
$params = new Bugzilla::CGI($::buffer); $params = new Bugzilla::CGI($::buffer);
$order = $params->param('order') || $order; $order = $params->param('order') || $order;
} }
elsif ($::FORM{'remaction'} eq "runseries") {
$::buffer = LookupSeries($::FORM{"series_id"});
$vars->{'title'} = "Bug List: $::FORM{'namedcmd'}";
$params = new Bugzilla::CGI($::buffer);
$order = $params->param('order') || $order;
}
elsif ($::FORM{'remaction'} eq "load") { elsif ($::FORM{'remaction'} eq "load") {
my $url = "query.cgi?" . LookupNamedQuery($::FORM{"namedcmd"}); my $url = "query.cgi?" . LookupNamedQuery($::FORM{"namedcmd"});
print "Refresh: 0; URL=$url\n"; print "Refresh: 0; URL=$url\n";
......
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