alecpl
2011-02-09 99897b7c4e52a5ff026c3828b84653f460f571f0
program/include/rcube_message.php
@@ -426,7 +426,7 @@
                        $mail_part->type = 'content';
                        $this->parts[] = $mail_part;
                    }
                    // list as attachment as well
                    if (!empty($mail_part->filename))
                        $this->attachments[] = $mail_part;
@@ -473,11 +473,26 @@
                    // attachment encapsulated within message/rfc822 part needs further decoding (#1486743)
                    else if ($part_orig_mimetype == 'message/rfc822') {
                        $this->parse_structure($mail_part, true);
                        // list as attachment as well (mostly .eml)
                        if (!empty($mail_part->filename))
                            $this->attachments[] = $mail_part;
                    }
                    // is a regular attachment (content-type name regexp according to RFC4288.4.2)
                    // regular attachment with valid content type
                    // (content-type name regexp according to RFC4288.4.2)
                    else if (preg_match('/^[a-z0-9!#$&.+^_-]+\/[a-z0-9!#$&.+^_-]+$/i', $part_mimetype)) {
                        if (!$mail_part->filename)
                            $mail_part->filename = 'Part '.$mail_part->mime_id;
                        $this->attachments[] = $mail_part;
                    }
                    // attachment with invalid content type
                    // replace malformed content type with application/octet-stream (#1487767)
                    else if ($mail_part->filename) {
                        $mail_part->ctype_primary   = 'application';
                        $mail_part->ctype_secondary = 'octet-stream';
                        $mail_part->mimetype        = 'application/octet-stream';
                        $this->attachments[] = $mail_part;
                    }
                }
@@ -502,6 +517,16 @@
                    ) {
                        $this->attachments[] = $inline_object;
                    }
                    // MS Outlook sometimes also adds non-image attachments as related
                    // We'll add all such attachments to the attachments list
                    // Warning: some browsers support pdf in <img/>
                    // @TODO: we should fetch HTML body and find attachment's content-id
                    // to handle also image attachments without reference in the body
                    if (!empty($inline_object->filename)
                        && !preg_match('/^image\/(gif|jpe?g|png|tiff|bmp|svg)/', $inline_object->mimetype)
                    ) {
                        $this->attachments[] = $inline_object;
                    }
                }
                // add replace array to each content part