diff options
author | David Lawrence <dlawrence@mozilla.com> | 2011-10-05 00:25:23 +0200 |
---|---|---|
committer | David Lawrence <dlawrence@mozilla.com> | 2011-10-05 00:25:23 +0200 |
commit | 57584dc4744fea59833ef355f7513690d246c70f (patch) | |
tree | 805f2b2941eca17eaf97263165d11d9e676ad9d1 /extensions/TypeSniffer | |
parent | 785580c6c290b93fe25868cfbb5d4e300749de62 (diff) | |
download | bugzilla-57584dc4744fea59833ef355f7513690d246c70f.tar.gz bugzilla-57584dc4744fea59833ef355f7513690d246c70f.tar.xz |
more porting work
Diffstat (limited to 'extensions/TypeSniffer')
-rw-r--r-- | extensions/TypeSniffer/Extension.pm | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/extensions/TypeSniffer/Extension.pm b/extensions/TypeSniffer/Extension.pm index ead4f40cf..fcd4f7dd6 100644 --- a/extensions/TypeSniffer/Extension.pm +++ b/extensions/TypeSniffer/Extension.pm @@ -42,28 +42,12 @@ sub attachment_process_data { if ($params->{'contenttypemethod'} eq 'autodetect' && $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 - my $fh = $attributes->{'data'}; + # data is either a filehandle, or the data itself + my $fh = ${$args->{'data'}}; if (!ref($fh)) { - my $data = $attributes->{'data'}; - $fh = new IO::Scalar \$data; + $fh = IO::Scalar->new(\$fh); } - else { - # CGI.pm sends us an Fh that isn't actually an IO::Handle, but - # has a method for getting an actual handle out of it. - if (!$fh->isa('IO::Handle')) { - $fh = $fh->handle; - # ->handle returns an literal IO::Handle, even though the - # underlying object is a file. So we rebless it to be a proper - # IO::File object so that we can call ->seek on it and so on. - # Just in case CGI.pm fixes this some day, we check ->isa first. - if (!$fh->isa('IO::File')) { - bless $fh, 'IO::File'; - } - } - } - + my $mimetype = mimetype($fh); if ($mimetype) { $attributes->{'mimetype'} = $mimetype; |