aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@netscape.net>2017-04-22 19:12:08 +0200
committerFrédéric Buclin <LpSolit@netscape.net>2017-04-22 19:12:08 +0200
commitb208d47874bf39eba5f9aec2e3890dd82c303e40 (patch)
treea4404b4aa0bc341b96e600811ccbeed6b9060c42
parentcf3fa62685f06f0325ef6cd0a700c278deba029f (diff)
downloadbugs-b208d47874bf39eba5f9aec2e3890dd82c303e40.tar
bugs-b208d47874bf39eba5f9aec2e3890dd82c303e40.tar.gz
bugs-b208d47874bf39eba5f9aec2e3890dd82c303e40.tar.bz2
bugs-b208d47874bf39eba5f9aec2e3890dd82c303e40.tar.xz
bugs-b208d47874bf39eba5f9aec2e3890dd82c303e40.zip
Backport upstream bug 622455: The attachment mime type autodetection
shouldn't rely on the browser when it gets text/x-*
-rw-r--r--Bugzilla/Attachment.pm8
1 files changed, 3 insertions, 5 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm
index 33183797b..14c81193d 100644
--- a/Bugzilla/Attachment.pm
+++ b/Bugzilla/Attachment.pm
@@ -501,9 +501,8 @@ sub _check_content_type {
# If we have autodetected application/octet-stream from the Content-Type
# header, let's have a better go using a sniffer if available.
- if (defined Bugzilla->input_params->{contenttypemethod}
- && Bugzilla->input_params->{contenttypemethod} eq 'autodetect'
- && $content_type eq 'application/octet-stream'
+ if ((Bugzilla->input_params->{contenttypemethod} // '') eq 'autodetect'
+ && ($content_type eq 'application/octet-stream' || $content_type =~ m{text/x-})
&& Bugzilla->feature('typesniffer'))
{
import File::MimeInfo::Magic qw(mimetype);
@@ -534,8 +533,7 @@ sub _check_content_type {
# Make sure patches are viewable in the browser
if (!ref($invocant)
- && defined Bugzilla->input_params->{contenttypemethod}
- && Bugzilla->input_params->{contenttypemethod} eq 'autodetect'
+ && (Bugzilla->input_params->{contenttypemethod} // '') eq 'autodetect'
&& $content_type =~ m{text/x-(?:diff|patch)})
{
$params->{ispatch} = 1;