From 47d06e46dfb5e8d616e578e5c04a263b526c7a06 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 28 Aug 2010 11:02:04 -0400
Subject: [PATCH] - Display inline images with known extensions and non-image content-type (#1486934)

---
 program/steps/mail/func.inc |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index ee33e9c..a87b784 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1025,7 +1025,13 @@
       && !empty($MESSAGE->attachments))
     {
     foreach ($MESSAGE->attachments as $attach_prop) {
-      if (strpos($attach_prop->mimetype, 'image/') === 0) {
+      // Content-Type: image/*...
+      if (preg_match('/^image\//i', $attach_prop->mimetype) ||
+        // ...or known file extension: many clients are using application/octet-stream
+        ($attach_prop->filename &&
+          preg_match('/^application\/octet-stream$/i', $attach_prop->mimetype) &&
+          preg_match('/\.(jpg|jpeg|png|gif|bmp)$/i', $attach_prop->filename))
+      ) {
         $out .= html::tag('hr') . html::p(array('align' => "center"),
           html::img(array(
             'src' => $MESSAGE->get_part_url($attach_prop->mime_id),

--
Gitblit v1.9.1