From 542f15bfece569ba3d07f57339aca22e535027dd Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Thu, 14 Mar 2013 07:17:38 -0400 Subject: [PATCH] Enriched content should be also converted to text if html is disabled --- program/steps/mail/compose.inc | 39 +++++++++++++++++++-------------------- 1 files changed, 19 insertions(+), 20 deletions(-) diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 379e920..6402724 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -509,7 +509,7 @@ function rcmail_compose_editor_mode() { - global $RCMAIL, $MESSAGE, $compose_mode; + global $RCMAIL, $compose_mode; static $useHtml; if ($useHtml !== null) @@ -521,13 +521,13 @@ $useHtml = !empty($_POST['_is_html']); } else if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) { - $useHtml = $MESSAGE->has_html_part(false, true); + $useHtml = rcmail_message_is_html(); } else if ($compose_mode == RCUBE_COMPOSE_REPLY) { - $useHtml = ($html_editor == 1 || ($html_editor >= 2 && $MESSAGE->has_html_part(false, true))); + $useHtml = ($html_editor == 1 || ($html_editor >= 2 && rcmail_message_is_html())); } else if ($compose_mode == RCUBE_COMPOSE_FORWARD) { - $useHtml = ($html_editor == 1 || ($html_editor == 3 && $MESSAGE->has_html_part(false, true))); + $useHtml = ($html_editor == 1 || ($html_editor == 3 && rcmail_message_is_html())); } else { $useHtml = ($html_editor == 1); @@ -536,6 +536,11 @@ return $useHtml; } +function rcmail_message_is_html() +{ + global $MESSAGE; + return ($MESSAGE instanceof rcube_message) && $MESSAGE->has_html_part(true); +} function rcmail_prepare_message_body() { @@ -669,9 +674,6 @@ $len = $compose_mode == RCUBE_COMPOSE_REPLY ? $LINE_LENGTH-2 : $LINE_LENGTH; $txt = new rcube_html2text($body, false, true, $len); $body = $txt->get_text(); - } - else if ($part->ctype_secondary == 'enriched') { - $body = rcube_enriched::to_html($body); } else { if ($part->ctype_secondary == 'plain' && $part->ctype_parameters['format'] == 'flowed') { @@ -978,11 +980,16 @@ { global $RCMAIL, $COMPOSE, $compose_mode; + $loaded_attachments = array(); + foreach ((array)$COMPOSE['attachments'] as $id => $attachment) { + $loaded_attachments[$attachment['name'] . $attachment['mimetype']] = $attachment; + } + $cid_map = $messages = array(); foreach ((array)$message->mime_parts as $pid => $part) { if ($part->disposition == 'attachment' || ($part->disposition == 'inline' && $bodyIsHtml) || $part->filename) { - if ($part->ctype_primary == 'message' || $part->ctype_primary == 'multipart') { + if (($part->ctype_primary == 'message' && $bodyIsHtml) || $part->ctype_primary == 'multipart') { continue; } if ($part->mimetype == 'application/ms-tnef') { @@ -1005,7 +1012,8 @@ } } - if (!$skip && ($attachment = rcmail_save_attachment($message, $pid))) { + if (!$skip && (($attachment = $loaded_attachments[rcmail_attachment_name($part) . $part->mimetype]) + || ($attachment = rcmail_save_attachment($message, $pid)))) { $COMPOSE['attachments'][$attachment['id']] = $attachment; if ($bodyIsHtml && ($part->content_id || $part->content_location)) { $url = sprintf('%s&_id=%s&_action=display-attachment&_file=rcmfile%s', @@ -1154,16 +1162,7 @@ } $mimetype = $part->ctype_primary . '/' . $part->ctype_secondary; - $filename = $part->filename; - if (!strlen($filename)) { - if ($mimetype == 'text/html') { - $filename = rcube_label('htmlmessage'); - } - else { - $filename = 'Part_'.$pid; - } - $filename .= '.' . $part->ctype_secondary; - } + $filename = rcmail_attachment_name($part); $attachment = array( 'group' => $COMPOSE['id'], @@ -1567,7 +1566,7 @@ $class_name .= ' ' . $source['class_name']; $out .= sprintf($line_templ, - html_identifier($id), + html_identifier($id,true), $class_name, $source['id'], $js_id, (!empty($source['name']) ? $source['name'] : $id)); -- Gitblit v1.9.1