summaryrefslogtreecommitdiff
path: root/program/include/rcube_shared.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2012-01-13 11:21:45 +0000
committeralecpl <alec@alec.pl>2012-01-13 11:21:45 +0000
commit4391a7809edae1b552f0720a43924212519900a9 (patch)
treec14ef87917408c1176a202a4551b609b58b96f78 /program/include/rcube_shared.inc
parentfd43a92b5d31bab019d9afec1c9846b7ab9291bb (diff)
- Make mime type detection based on filename extension to be case-insensitive
Diffstat (limited to 'program/include/rcube_shared.inc')
-rw-r--r--program/include/rcube_shared.inc10
1 files changed, 7 insertions, 3 deletions
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index aef08341d..6767c93e7 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -362,12 +362,14 @@ function rc_mime_content_type($path, $name, $failover = 'application/octet-strea
$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 @@ function rc_mime_content_type($path, $name, $failover = 'application/octet-strea
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;