From d311d809d650e4cab6a5bf0aeb92b97631672c64 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 28 May 2010 05:38:41 -0400
Subject: [PATCH] - 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

---
 program/include/rcube_shared.inc |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index 2c3e639..3ab7691 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -430,16 +430,17 @@
 /**
  * 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 @@
     // 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) {

--
Gitblit v1.9.1