From 3c36bcc3293e1c3eb8d187c3e07014527f012ccf Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 13 Jan 2012 06:23:17 -0500
Subject: [PATCH] - Backported r5769 from trunk
---
CHANGELOG | 1 +
program/include/rcube_shared.inc | 10 +++++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8140e2e..a00f510 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Make mime type detection based on filename extension to be case-insensitive
- Fix failure on MySQL database upgrade from 0.7 - text column can't have default value (#1488300)
RELEASE 0.7.1
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index aef0834..6767c93 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -362,12 +362,14 @@
$mime_type = null;
$mime_magic = rcmail::get_instance()->config->get('mime_magic');
$mime_ext = @include(RCMAIL_CONFIG_DIR . '/mimetypes.php');
- $suffix = $name ? substr($name, strrpos($name, '.')+1) : '*';
// use file name suffix with hard-coded mime-type map
- if (is_array($mime_ext)) {
- $mime_type = $mime_ext[$suffix];
+ if (is_array($mime_ext) && $name) {
+ if ($suffix = substr($name, strrpos($name, '.')+1)) {
+ $mime_type = $mime_ext[strtolower($suffix)];
+ }
}
+
// try fileinfo extension if available
if (!$mime_type && function_exists('finfo_open')) {
if ($finfo = finfo_open(FILEINFO_MIME, $mime_magic)) {
@@ -378,10 +380,12 @@
finfo_close($finfo);
}
}
+
// try PHP's mime_content_type
if (!$mime_type && !$is_stream && function_exists('mime_content_type')) {
$mime_type = @mime_content_type($path);
}
+
// fall back to user-submitted string
if (!$mime_type) {
$mime_type = $failover;
--
Gitblit v1.9.1