From 4f69328132beae439d1aecb6d35d55392e480eca Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Mon, 12 Oct 2009 06:37:49 -0400 Subject: [PATCH] - Partially fixed "empty body" issue by showing raw body of malformed message (#1486166) --- program/include/rcube_imap.php | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index bfe2845..533f941 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -602,7 +602,8 @@ if ($this->index_sort && $this->sort_field == 'date') { if ($this->skip_deleted) { - $msg_index = $this->_search_index($mailbox, 'ALL'); + // @TODO: this could be cached + $msg_index = $this->_search_index($mailbox, 'ALL UNDELETED'); $max = max($msg_index); list($begin, $end) = $this->_get_message_range(count($msg_index), $page); $msg_index = array_slice($msg_index, $begin, $end-$begin); @@ -1225,6 +1226,16 @@ else $this->struct_charset = $this->_structure_charset($structure); + // Here we can recognize malformed BODYSTRUCTURE and + // 1. [@TODO] parse the message in other way to create our own message structure + // 2. or just show the raw message body. + // Example of structure for malformed MIME message: + // ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 2154 70 NIL NIL NIL) + if ($headers->ctype && $headers->ctype != 'text/plain' + && $structure[0] == 'text' && $structure[1] == 'plain') { + return false; + } + $struct = &$this->_structure_part($structure); $struct->headers = get_object_vars($headers); @@ -1542,7 +1553,7 @@ // convert charset (if text or message part) if ($o_part->ctype_primary=='text' || $o_part->ctype_primary=='message') { // assume default if no charset specified - if (empty($o_part->charset)) + if (empty($o_part->charset) || strtolower($o_part->charset) == 'us-ascii') $o_part->charset = $this->default_charset; $body = rcube_charset_convert($body, $o_part->charset); -- Gitblit v1.9.1