[Tickets #746] NEW: IMP_Compose->findBody() does not select from multipart/alternatives

bugs at bugs.horde.org bugs at bugs.horde.org
Mon Nov 1 21:25:33 PST 2004


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/?id=746
-----------------------------------------------------------------------
 Ticket     | 746
 Created By | ctnpublic-horde at yahoo.com
 Summary    | IMP_Compose->findBody() does not select from multipart/alternatives
 Queue      | IMP
 Version    | HEAD
 State      | New
 Priority   | 2. Medium
 Type       | Enhancement
 Owners     | 
-----------------------------------------------------------------------


ctnpublic-horde at yahoo.com (2004-11-01 21:25) wrote:

It takes the whole thing, i.e., all alternatives. Hence such messages are
duplicated in the reply (plain and html). As an additional side effect,
there is no quoted-printable decoding of the sub-parts, so user sees all the
confusing encoding characters.

Suggest enhancement to select out one of the alternatives and apply proper
decoding to it, e.g.,
cvs diff -u -r HEAD imp/lib/Compose.php
Index: imp/lib/Compose.php
===================================================================
RCS file: /repository/imp/lib/Compose.php,v
retrieving revision 1.105
diff -u -r1.105 Compose.php
--- imp/lib/Compose.php 2 Nov 2004 01:56:02 -0000       1.105
+++ imp/lib/Compose.php 2 Nov 2004 05:23:51 -0000
@@ -154,7 +154,6 @@
         }

         $mime_part = &$imp_contents->getDecodedMIMEPart($this->_mimeid);
-        $body = $mime_part->getContents();

         //if ($mime_message->getType() == 'multipart/encrypted') {
             /* TODO: Maybe someday I can figure out how to show embedded
@@ -162,6 +161,28 @@
         //    return '[' . _("Original message was encrypted") . ']';
         //}

+       if ($mime_part->getType() == 'multipart/alternative')
+       {
+           // Select the text/plain  alternative if possible, else
text/html, else all
+           $parts = $mime_part->getParts();
+           $prefTypes = array('text/plain', 'text/html');
+           $done = false;
+           for ($i = 0; !$done && $i < count($prefTypes); $i++)
+           {
+               for ($j = 1; !$done && $j <= count($parts); $j++)
+               {
+                   if ($parts[$j]->getType() == $prefTypes[$i])
+                   {
+                       $mime_part = $parts[$j];
+                       $mime_part->transferDecodeContents();
+                       $done = true;
+                   }
+               }
+           }
+       }
+
+        $body = $mime_part->getContents();
+
         if ($mime_part->getSubType() == 'html') {
             require_once 'Horde/Text/Filter.php';
             return Text_Filter::filter($body, 'html2text');








More information about the bugs mailing list