summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorGervase Markham <gerv@gerv.net>2013-01-02 18:09:36 +0100
committerGervase Markham <gerv@mozilla.org>2013-01-02 18:09:36 +0100
commit21b50cba4e08e723f8c2d8e8b5800d0a13e2c180 (patch)
tree504bae35d3f49fbbc951567fe07068294a949393 /Bugzilla
parentdb29480b097468be60ff0ffbc4344166443ae525 (diff)
downloadbugzilla-21b50cba4e08e723f8c2d8e8b5800d0a13e2c180.tar.gz
bugzilla-21b50cba4e08e723f8c2d8e8b5800d0a13e2c180.tar.xz
Bug 413851 - add CSV output option to request lists. r=LpSolit.
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/CGI.pm25
1 files changed, 25 insertions, 0 deletions
diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm
index cb92800f1..513babd4f 100644
--- a/Bugzilla/CGI.pm
+++ b/Bugzilla/CGI.pm
@@ -281,6 +281,10 @@ sub header {
unshift(@_, '-type' => shift(@_));
}
+ if ($self->{'_content_disp'}) {
+ unshift(@_, '-content_disposition' => $self->{'_content_disp'});
+ }
+
# Add the cookies in if we have any
if (scalar(@{$self->{Bugzilla_cookie_list}})) {
unshift(@_, '-cookie' => $self->{Bugzilla_cookie_list});
@@ -528,6 +532,22 @@ sub url_is_attachment_base {
return ($self->self_url =~ $regex) ? 1 : 0;
}
+sub set_dated_content_disp {
+ my ($self, $type, $prefix, $ext) = @_;
+
+ my @time = localtime(time());
+ my $date = sprintf "%04d-%02d-%02d", 1900+$time[5], $time[4]+1, $time[3];
+ my $filename = "$prefix-$date.$ext";
+
+ $filename =~ s/\s/_/g; # Remove whitespace to avoid HTTP header tampering
+ $filename =~ s/\\/_/g; # Remove backslashes as well
+ $filename =~ s/"/\\"/g; # escape quotes
+
+ my $disposition = "$type; filename=\"$filename\"";
+
+ $self->{'_content_disp'} = $disposition;
+}
+
##########################
# Vars TIEHASH Interface #
##########################
@@ -635,6 +655,11 @@ instead of calling this directly.
Redirects from the current URL to one prefixed by the urlbase parameter.
+=item C<set_dated_content_disp>
+
+Sets an appropriate date-dependent value for the Content Disposition header
+for a downloadable resource.
+
=back
=head1 SEE ALSO