alecpl
2010-09-06 372d3bf6dead9800d75a39ebfcd884da5128b64f
program/include/rcube_imap.php
@@ -1704,14 +1704,22 @@
        else
            $this->struct_charset = $this->_structure_charset($structure);
        $headers->ctype = strtolower($headers->ctype);
        // 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;
        // ("text" "plain" NIL NIL NIL "7bit" 2154 70 NIL NIL NIL)
        if ($headers->ctype && !is_array($structure[0]) && $headers->ctype != 'text/plain'
            && strtolower($structure[0].'/'.$structure[1]) == 'text/plain') {
            // we can handle single-part messages, by simple fix in structure (#1486898)
            if (preg_match('/^(text|application)\/(.*)/', $headers->ctype, $m)) {
                $structure[0] = $m[1];
                $structure[1] = $m[2];
            }
            else
                return false;
        }
        $struct = &$this->_structure_part($structure);
@@ -2231,11 +2239,8 @@
        // make sure mailbox exists
        if ($this->mailbox_exists($mbox_name, true)) {
            if ($is_file) {
                $separator = rcmail::get_instance()->config->header_delimiter();
                $saved = $this->conn->appendFromFile($mailbox, $message,
                    $headers, $separator.$separator);
            }
            if ($is_file)
                $saved = $this->conn->appendFromFile($mailbox, $message, $headers);
            else
                $saved = $this->conn->append($mailbox, $message);
        }