summaryrefslogtreecommitdiff
path: root/program/include/rcube_shared.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-05-28 09:38:41 +0000
committeralecpl <alec@alec.pl>2010-05-28 09:38:41 +0000
commitd311d809d650e4cab6a5bf0aeb92b97631672c64 (patch)
tree80ae4736c520debf7fb9e0fd5e2117c3256cc886 /program/include/rcube_shared.inc
parent89e31bec153c28896c177c1d5e652b38d5d8a55f (diff)
- Fix forwarding of messages with winmail attachments
- Remove some redundant code for winmail handling in get.inc, move tnef_decode() to rcube_message - Fix handling of uuencoded attachments in message body (#1485839) - Extend rc_mime_content_type() to work with string buffer
Diffstat (limited to 'program/include/rcube_shared.inc')
-rw-r--r--program/include/rcube_shared.inc18
1 files changed, 11 insertions, 7 deletions
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index 2c3e63933..3ab76917d 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -430,16 +430,17 @@ function abbreviate_string($str, $maxlength, $place_holder='...')
/**
* A method to guess the mime_type of an attachment.
*
- * @param string $path Path to the file.
- * @param string $name File name (with suffix)
- * @param string $failover Mime type supplied for failover.
+ * @param string $path Path to the file.
+ * @param string $name File name (with suffix)
+ * @param string $failover Mime type supplied for failover.
+ * @param string $is_stream Set to True if $path contains file body
*
* @return string
* @author Till Klampaeckel <till@php.net>
* @see http://de2.php.net/manual/en/ref.fileinfo.php
* @see http://de2.php.net/mime_content_type
*/
-function rc_mime_content_type($path, $name, $failover = 'application/octet-stream')
+function rc_mime_content_type($path, $name, $failover = 'application/octet-stream', $is_stream=false)
{
$mime_type = null;
$mime_magic = rcmail::get_instance()->config->get('mime_magic');
@@ -453,13 +454,16 @@ function rc_mime_content_type($path, $name, $failover = 'application/octet-strea
// try fileinfo extension if available
if (!$mime_type && function_exists('finfo_open')) {
if ($finfo = finfo_open(FILEINFO_MIME, $mime_magic)) {
- $mime_type = finfo_file($finfo, $path);
+ if ($is_stream)
+ $mime_type = finfo_buffer($finfo, $path);
+ else
+ $mime_type = finfo_file($finfo, $path);
finfo_close($finfo);
}
}
// try PHP's mime_content_type
- if (!$mime_type && function_exists('mime_content_type')) {
- $mime_type = mime_content_type($path);
+ 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) {