Ticket #1483998 (new Bugs)

Opened 2 years ago

Last modified 7 weeks ago

Attachment not show when "name" or "filename" span multiple lines

Reported by: maharaja Owned by:
Priority: 5 Milestone:
Component: Core functionality Version: 0.1-beta
Severity: normal Keywords:
Cc:

Description

I composed an email with mozill thunderbird 1.5.x (newest version today).

when viewing the email via roundcube it did not show any attachment. i think that this might be the result from the "name" or the "filename" spanning multiple lines.

even uudeview 0.5pl20 on debian does not parse the real name.

--------------070305060308020809050003
Content-Type: application/pdf;
 name*0="Einladung der Pfadfindergruppe Klosterneuburg - 80 Jahre Karl Ba";
 name*1="rteis Bleibe.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename*0="Einladung der Pfadfindergruppe Klosterneuburg - 80 Jahre Kar";
 filename*1="l Barteis Bleibe.pdf"

Change History

Changed 2 years ago by thomasb

Is that in RFC?

Changed 6 months ago by till

  • milestone set to 0.1.5

Changed 3 months ago by anonymous

  • milestone deleted

Milestone 0.1.5 deleted

Changed 7 weeks ago by ryanlim

I seemed to be having this issue too. I dug a little into it and found out that my imap server (dovecot 1.0.0) doesn't do rfc2231 when doing a fetch bodystructure.

This is my patch (it probably isn't the best). It patches againsts program/include/rcube_imap.php

Index: rcube_imap.php
===================================================================
--- rcube_imap.php	(revision 1587)
+++ rcube_imap.php	(working copy)
@@ -1030,6 +1030,29 @@
 
     $structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $msg_id); 
     $structure = iml_GetRawStructureArray($structure_str);
+
+    require_once 'Mail/mimeDecode.php';
+    $rl_body  = iil_C_FetchPartHeader($this->conn, $this->mailbox, $msg_id, NULL);
+    $rl_body .= iil_C_FetchPartBody($this->conn, $this->mailbox, $msg_id, NULL, 1); 
+    $rl_mime = new Mail_mimeDecode($rl_body);
+    $rl_decoded = $rl_mime->decode();
+    $rl_obj_update = array();
+    foreach ($rl_decoded->parts as $rl_part_key => $rl_part) {
+        if (isset($rl_part->ctype_parameters)) {
+            $keys = array_keys($rl_part->ctype_parameters);
+            foreach ($keys as $k) {
+                $strpos_res = strpos($k, 'name');
+                if ($strpos_res !== false) {
+                    $rl_attach_name = $rl_part->ctype_parameters[$k];
+                    $rl_attach_name = preg_replace('/" name\*[\d+]\*="/', '', $rl_attach_name);
+
+                    $rl_obj_update[$rl_part_key]['name'] = $rl_attach_name;
+                }
+            }
+        }
+    }
+
+
     $struct = false;
 
     // parse structure and add headers
@@ -1053,7 +1076,29 @@
       if ($this->caching_enabled)
         $this->add_message_cache($cache_key, $msg_id, $headers, $struct);
       }
-      
+
+    foreach ($rl_obj_update as $rl_update_key => $rl_update) {
+
+        $keys = array_keys($struct->parts[$rl_update_key]->ctype_parameters);
+        foreach ($keys as $k) {
+            $strpos_res = strpos($k, 'name');
+            if ($strpos_res !== false) {
+                unset( $struct->parts[$rl_update_key]->ctype_parameters[$k]);
+            }
+        }
+
+        $rl_filename = $rl_obj_update[$rl_update_key]['name'];
+        if (strpos($rl_obj_update[$rl_update_key]['name'], "''") !== false) {
+            list($tmp, $rl_filename) = explode("''", $rl_obj_update[$rl_update_key]['name']);
+            $rl_filename = urldecode($rl_filename);
+        }
+
+        $struct->parts[$rl_update_key]->filename = $rl_filename;
+
+        $struct->parts[$rl_update_key]->ctype_parameters['name'] = $rl_obj_update[$rl_part_key]['name'];
+        $struct->parts[$rl_update_key]->d_parameters['filename'] = $rl_obj_update[$rl_part_key]['name'];
+    }
+
     return $struct;
     }
 
Note: See TracTickets for help on using tickets.