From 3221c95a29c19677ff7c82e259aa683de4c224e7 Mon Sep 17 00:00:00 2001
From: svncommit <devs@roundcube.net>
Date: Tue, 15 Feb 2011 09:33:45 -0500
Subject: [PATCH] Update dutch translations.

---
 program/include/rcube_message.php |   48 ++++++++++++++++++++++++++++++------------------
 1 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/program/include/rcube_message.php b/program/include/rcube_message.php
index ec034db..a8c51cc 100644
--- a/program/include/rcube_message.php
+++ b/program/include/rcube_message.php
@@ -478,10 +478,21 @@
                         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;
                     }
                 }
@@ -490,6 +501,7 @@
             // if this was a related part try to resolve references
             if ($mimetype == 'multipart/related' && sizeof($this->inline_parts)) {
                 $a_replaces = array();
+                $img_regexp = '/^image\/(gif|jpe?g|png|tiff|bmp|svg)/';
 
                 foreach ($this->inline_parts as $inline_object) {
                     $part_url = $this->get_part_url($inline_object->mime_id);
@@ -498,23 +510,23 @@
                     if ($inline_object->content_location) {
                         $a_replaces[$inline_object->content_location] = $part_url;
                     }
-                    // MS Outlook sends sometimes non-related attachments as related
-                    // In this case multipart/related message has only one text part
-                    // We'll add all such attachments to the attachments list
-                    if (!isset($got_html_part) && empty($inline_object->content_id)
-                        && !empty($inline_object->filename)
-                    ) {
-                        $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;
+
+                    if (!empty($inline_object->filename)) {
+                        // MS Outlook sends sometimes non-related attachments as related
+                        // In this case multipart/related message has only one text part
+                        // We'll add all such attachments to the attachments list
+                        if (!isset($got_html_part) && empty($inline_object->content_id)) {
+                            $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/>
+                        else if (!preg_match($img_regexp, $inline_object->mimetype)) {
+                            $this->attachments[] = $inline_object;
+                        }
+                        // @TODO: we should fetch HTML body and find attachment's content-id
+                        // to handle also image attachments without reference in the body
+                        // @TODO: should we list all image attachments in text mode?
                     }
                 }
 

--
Gitblit v1.9.1