6.0.0-beta1
12/21/25

[#746] IMP_Compose->findBody() does not select from multipart/alternatives
Summary IMP_Compose->findBody() does not select from multipart/alternatives
Queue IMP
Queue Version HEAD
Type Enhancement
State Resolved
Priority 2. Medium
Owners slusarz (at) horde (dot) org
Requester ctnpublic-horde (at) yahoo (dot) com
Created 11/02/2004 (7719 days ago)
Due
Updated 11/02/2004 (7719 days ago)
Assigned 11/02/2004 (7719 days ago)
Resolved 11/02/2004 (7719 days ago)
Milestone
Patch No

History
11/02/2004 04:40:44 PM Jan Schneider State ⇒ Resolved
 
11/02/2004 04:36:38 PM ctnpublic-horde (at) yahoo (dot) com Comment #5 Reply to this comment
You are right. This is bogus. My imp/lib/MIME/Contents.php is out of sync.
11/02/2004 03:48:51 PM Michael Slusarz Comment #4 Reply to this comment
11/02/2004 10:05:56 AM ctnpublic-horde (at) yahoo (dot) com Comment #3 Reply to this comment
You mean reproduce (a) findBody() getting a multipart/alternative, or 
(b) findBody() not selecting one from among the alternatives?



I didn't think to investigate (a) (it seems reasonable given a 
multipart message), but once that's the case, (b) pretty certainly 
follows.
11/02/2004 08:53:27 AM Jan Schneider Comment #2
Assigned to Michael Slusarz
State ⇒ Assigned
Reply to this comment
I can't reproduce this, by the way.
11/02/2004 05:25:32 AM ctnpublic-horde (at) yahoo (dot) com Comment #1
State ⇒ New
Priority ⇒ 2. Medium
Type ⇒ Enhancement
Summary ⇒ IMP_Compose->findBody() does not select from multipart/alternatives
Queue ⇒ IMP
Reply to this comment
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');








Saved Queries