Aleksander Machniak
2012-12-30 cb0f030ae98a51398bd01e3d5075c8e939d944bc
program/lib/Roundcube/rcube_message.php
@@ -106,7 +106,6 @@
        if (!empty($this->headers->structure)) {
            $this->get_mime_numbers($this->headers->structure);
            $this->parse_structure($this->headers->structure);
            $this->parse_attachments();
        }
        else {
            $this->body = $this->storage->get_body($uid);
@@ -386,7 +385,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) {
@@ -561,7 +560,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']);
@@ -600,7 +599,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)/';
@@ -646,26 +645,6 @@
        // message is a single part non-text (without filename)
        else if (preg_match('/application\//i', $mimetype)) {
            $this->attachments[] = $structure;
        }
    }
    /**
     * Parse attachment parts
     */
    private function parse_attachments()
    {
        // Attachment must have a name
        foreach ($this->attachments as $attachment) {
            if (!$attachment->filename) {
                $ext = rcube_mime::get_mime_extensions($attachment->mimetype);
                $ext = array_shift($ext);
                $attachment->filename = 'Part_' . $attachment->mime_id;
                if ($ext) {
                    $attachment->filename .= '.' . $ext;
                }
            }
        }
    }