From 5cc4b13a0c6d32d74d0cba17feeb6c5fbceaf25f Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Mon, 19 Mar 2007 18:36:24 -0400
Subject: [PATCH] Correctly parse message/rfc822; fixed html2text conversion; code cleanup

---
 program/steps/mail/compose.inc |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 1c2639d..a794e98 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -401,8 +401,8 @@
       $body = rcmail_first_text_part($MESSAGE);
       $isHtml = false;
       }
-    if (strlen($body))
-      $body = rcmail_create_forward_body($body, $isHtml);
+
+    $body = rcmail_create_forward_body($body, $isHtml);
     }
   else if ($compose_mode == RCUBE_COMPOSE_DRAFT)
     {
@@ -564,10 +564,9 @@
   }
 
   // add attachments
-  if (!isset($_SESSION['compose']['forward_attachments']) &&
-      is_array($MESSAGE['parts']) && sizeof($MESSAGE['parts'])>1)
+  if (!isset($_SESSION['compose']['forward_attachments']) && is_array($MESSAGE['parts']))
     rcmail_write_compose_attachments($MESSAGE);
-
+    
   return $prefix.$body;
   }
 
@@ -598,7 +597,7 @@
     {
     if ($part->ctype_primary != 'message' && $part->ctype_primary != 'text' &&
         ($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] ||
-         (empty($part->disposition) && ($part->d_parameters['filename'] || $part->ctype_parameters['name']))))
+         (empty($part->disposition) && $part->filename)))
       {
       $tmp_path = tempnam($temp_dir, 'rcmAttmnt');
       if ($fp = fopen($tmp_path, 'w'))
@@ -606,13 +605,9 @@
         fwrite($fp, $IMAP->get_message_part($message['UID'], $pid, $part->encoding));
         fclose($fp);
         
-        $filename = !empty($part->d_parameters['filename']) ? $part->d_parameters['filename'] :
-                     (!empty($part->ctype_parameters['name']) ? $part->ctype_parameters['name'] :
-                      (!empty($part->headers['content-description']) ? $part->headers['content-description'] : 'file'));
-
         $_SESSION['compose']['attachments'][] = array(
-          'name' => rcube_imap::decode_mime_string($filename),
           'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary,
+          'name' => $part->filename,
           'path' => $tmp_path
           );
         }

--
Gitblit v1.9.1