diff options
author | Byron Jones <bjones@mozilla.com> | 2013-03-14 17:50:49 +0100 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2013-03-14 17:50:49 +0100 |
commit | c2458a43c577d205ef565c8e940444c1eb131983 (patch) | |
tree | 1bf0c4638ad08822c679198e8fc813185f32398d /extensions | |
parent | 31e01144e6933e84abd768adc766ff7db5d03a4e (diff) | |
download | bugzilla-c2458a43c577d205ef565c8e940444c1eb131983.tar.gz bugzilla-c2458a43c577d205ef565c8e940444c1eb131983.tar.xz |
Bug 848457: TypeSniffer is chopping the first 32 bytes from attachments
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/TypeSniffer/Extension.pm | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/extensions/TypeSniffer/Extension.pm b/extensions/TypeSniffer/Extension.pm index bf9d9e856..78ecdcbef 100644 --- a/extensions/TypeSniffer/Extension.pm +++ b/extensions/TypeSniffer/Extension.pm @@ -29,19 +29,19 @@ use IO::Scalar; our $VERSION = '0.02'; ################################################################################ # This extension uses magic to guess MIME types for data where the browser has -# told us it's application/octet-stream (probably because there's no file +# told us it's application/octet-stream (probably because there's no file # extension, or it's a text type with a non-.txt file extension). ################################################################################ sub attachment_process_data { my ($self, $args) = @_; my $attributes = $args->{'attributes'}; my $params = Bugzilla->input_params; - + # If we have autodetected application/octet-stream from the Content-Type # header, let's have a better go using a sniffer. if ($params->{'contenttypemethod'} && $params->{'contenttypemethod'} eq 'autodetect' && - $attributes->{'mimetype'} eq 'application/octet-stream') + $attributes->{'mimetype'} eq 'application/octet-stream') { # data attribute can be either scalar data or filehandle # bugzilla.org/docs/3.6/en/html/api/Bugzilla/Attachment.html#create @@ -62,10 +62,11 @@ sub attachment_process_data { if (!$fh->isa('IO::File')) { bless $fh, 'IO::File'; } - } + } } - + my $mimetype = mimetype($fh); + $fh->seek(0, 0); if ($mimetype) { $attributes->{'mimetype'} = $mimetype; } |