From 02b6e614ca7fc60dfd5e13669a1c941c0f4190e6 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 03 Feb 2011 13:59:59 -0500
Subject: [PATCH] - Fix handling of non-image attachments in multipart/related messages (#1487750) 

---
 CHANGELOG                         |    1 +
 program/include/rcube_message.php |   10 ++++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index af40cf6..6bade2a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix handling of non-image attachments in multipart/related messages (#1487750)
 - Fix IDNA support when IDN/INTL modules are in use (#1487742)
 - Fix handling of invalid HTML comments in messages (#1487759)
 - Fix parsing FETCH response for very long headers (#1487753)
diff --git a/program/include/rcube_message.php b/program/include/rcube_message.php
index af91b80..ec034db 100644
--- a/program/include/rcube_message.php
+++ b/program/include/rcube_message.php
@@ -506,6 +506,16 @@
                     ) {
                         $this->attachments[] = $inline_object;
                     }
+                    // MS Outlook sometimes also adds non-image attachments as related
+                    // We'll add all such attachments to the attachments list
+                    // Warning: some browsers support pdf in <img/>
+                    // @TODO: we should fetch HTML body and find attachment's content-id
+                    // to handle also image attachments without reference in the body
+                    if (!empty($inline_object->filename)
+                        && !preg_match('/^image\/(gif|jpe?g|png|tiff|bmp|svg)/', $inline_object->mimetype)
+                    ) {
+                        $this->attachments[] = $inline_object;
+                    }
                 }
 
                 // add replace array to each content part

--
Gitblit v1.9.1