]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 622455: The attachment mime type autodetection shouldn't rely on the browser...
authorFrédéric Buclin <LpSolit@gmail.com>
Wed, 29 Apr 2015 09:41:00 +0000 (11:41 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Wed, 29 Apr 2015 09:41:00 +0000 (11:41 +0200)
r=dkl a=glob

Bugzilla/Attachment.pm

index ed770ad894c739219357aaa3f894158ff05664ea..ed43cbe94d307a671b180b4362b358f3f9f8f0c5 100644 (file)
@@ -541,9 +541,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);
@@ -574,8 +573,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;