Commit 376c76bd authored by kiko%async.com.br's avatar kiko%async.com.br

Fix for bug 111522: Provide ability to specify MIME type of attachment

when downloading. Adds a 'ctype' argument to attachment.cgi which allows one to override the content-type when viewing an attachment. Original patch by Alex Vincent <ajvincent@juno.com>; I changed it a tiny bit. r=kiko, myk. a=justdave.
parent 77c68c2b
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
# Myk Melez <myk@mozilla.org> # Myk Melez <myk@mozilla.org>
# Daniel Raichle <draichle@gmx.net> # Daniel Raichle <draichle@gmx.net>
# Dave Miller <justdave@syndicomm.com> # Dave Miller <justdave@syndicomm.com>
# Alexander J. Vincent <ajvincent@juno.com>
################################################################################ ################################################################################
# Script Initialization # Script Initialization
...@@ -433,6 +434,15 @@ sub view ...@@ -433,6 +434,15 @@ sub view
# Retrieve the attachment content and its content type from the database. # Retrieve the attachment content and its content type from the database.
SendSQL("SELECT mimetype, filename, thedata FROM attachments WHERE attach_id = $::FORM{'id'}"); SendSQL("SELECT mimetype, filename, thedata FROM attachments WHERE attach_id = $::FORM{'id'}");
my ($contenttype, $filename, $thedata) = FetchSQLData(); my ($contenttype, $filename, $thedata) = FetchSQLData();
# Bug 111522: allow overriding content-type manually in the posted $::FORM.
if ($::FORM{'ctype'})
{
$::FORM{'contenttypemethod'} = 'manual';
$::FORM{'contenttypeentry'} = $::FORM{'ctype'};
validateContentType();
$contenttype = $::FORM{'ctype'};
}
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
$filename =~ s/^.*[\/\\]//; $filename =~ s/^.*[\/\\]//;
......
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