X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=program%2Finclude%2Frcube_shared.inc;fp=program%2Finclude%2Frcube_shared.inc;h=089aab4003fc2703c5b5c429d74641be2fe5de30;hb=b06ca1de90262dfb6d8eabe9a4037a8e36e930cc;hp=fcab42950347b047d1c44983d2f4b0dd5b7d8fe3;hpb=5058e04171cbe6d82a65fc9d869ddef90e829e36;p=roundcube.git diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc index fcab429..089aab4 100644 --- a/program/include/rcube_shared.inc +++ b/program/include/rcube_shared.inc @@ -15,7 +15,7 @@ | Author: Thomas Bruederli | +-----------------------------------------------------------------------+ - $Id: rcube_shared.inc 5715 2012-01-05 10:28:24Z alec $ + $Id: rcube_shared.inc 5770 2012-01-13 11:23:17Z alec $ */ @@ -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;