Aleksander Machniak
2013-03-13 58993ffcbbfb8b362ebf9d088125fb73d7f6cbed
program/lib/Roundcube/rcube_message.php
@@ -210,18 +210,20 @@
                if (!$recursive) {
                    $level = explode('.', $part->mime_id);
                    // Skip if level too deep or part has a file name
                    if (count($level) > 2 || $part->filename) {
                    // Skip if part is an attachment
                    if ($this->is_attachment($part)) {
                        continue;
                    }
                    // HTML part can be on the lower level, if not...
                    if (count($level) > 1) {
                        array_pop($level);
                    // Check if the part belongs to higher-level's alternative/related
                    while (array_pop($level) !== null) {
                        if (!count($level)) {
                            return true;
                        }
                        $parent = $this->mime_parts[join('.', $level)];
                        // ... parent isn't multipart/alternative or related
                        if ($parent->mimetype != 'multipart/alternative' && $parent->mimetype != 'multipart/related') {
                            continue;
                            continue 2;
                        }
                    }
                }
@@ -322,7 +324,7 @@
            // parse headers from message/rfc822 part
            if (!isset($structure->headers['subject'])) {
                list($headers, $dump) = explode("\r\n\r\n", $this->get_part_content($structure->mime_id, null, true, 4096));
                list($headers, $dump) = explode("\r\n\r\n", $this->get_part_content($structure->mime_id, null, true, 8192));
                $structure->headers = rcube_mime::parse_headers($headers);
            }
        }
@@ -385,7 +387,7 @@
            // get html/plaintext parts, other add to attachments list
            foreach ($structure->parts as $p => $sub_part) {
                $sub_mimetype = $sub_part->mimetype;
                $is_multipart = in_array($sub_mimetype, array('multipart/related', 'multipart/mixed', 'multipart/alternative'));
                $is_multipart = preg_match('/^multipart\/(related|relative|mixed|alternative)/', $sub_mimetype);
                // skip empty text parts
                if (!$sub_part->size && !$is_multipart) {
@@ -465,6 +467,17 @@
            $p->ctype_secondary = 'plain';
            $p->mimetype        = 'text/plain';
            $p->realtype        = 'multipart/encrypted';
            $this->parts[] = $p;
        }
        // this is an S/MIME ecrypted message -> create a plaintext body with the according message
        else if ($mimetype == 'application/pkcs7-mime') {
            $p = new stdClass;
            $p->type            = 'content';
            $p->ctype_primary   = 'text';
            $p->ctype_secondary = 'plain';
            $p->mimetype        = 'text/plain';
            $p->realtype        = 'application/pkcs7-mime';
            $this->parts[] = $p;
        }
@@ -560,7 +573,7 @@
                        continue;
                    // part belongs to a related message and is linked
                    if ($mimetype == 'multipart/related'
                    if (preg_match('/^multipart\/(related|relative)/', $mimetype)
                        && ($mail_part->headers['content-id'] || $mail_part->headers['content-location'])) {
                        if ($mail_part->headers['content-id'])
                            $mail_part->content_id = preg_replace(array('/^</', '/>$/'), '', $mail_part->headers['content-id']);
@@ -599,7 +612,7 @@
            }
            // if this was a related part try to resolve references
            if ($mimetype == 'multipart/related' && sizeof($this->inline_parts)) {
            if (preg_match('/^multipart\/(related|relative)/', $mimetype) && sizeof($this->inline_parts)) {
                $a_replaces = array();
                $img_regexp = '/^image\/(gif|jpe?g|png|tiff|bmp|svg)/';