[Svn] r3885 - in trunk/roundcubemail: . program/include

trac at roundcube.net trac at roundcube.net
Mon Aug 9 15:30:17 CEST 2010


Author: alec
Date: 2010-08-09 08:30:17 -0500 (Mon, 09 Aug 2010)
New Revision: 3885

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/include/rcube_imap.php
Log:
- Improve handling of single-part messages with bogus BODYSTRUCTURE (#1486898)


Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2010-08-09 06:53:23 UTC (rev 3884)
+++ trunk/roundcubemail/CHANGELOG	2010-08-09 13:30:17 UTC (rev 3885)
@@ -1,6 +1,8 @@
 CHANGELOG RoundCube Webmail
 ===========================
 
+- Improve handling of single-part messages with bogus BODYSTRUCTURE (#1486898)
+
 RELEASE 0.4
 -----------
 - Fix disapearing upload form disapears when user selects a file on Safari (#1486823)

Modified: trunk/roundcubemail/program/include/rcube_imap.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_imap.php	2010-08-09 06:53:23 UTC (rev 3884)
+++ trunk/roundcubemail/program/include/rcube_imap.php	2010-08-09 13:30:17 UTC (rev 3885)
@@ -1704,14 +1704,22 @@
         else
             $this->struct_charset = $this->_structure_charset($structure);
 
+        $headers->ctype = strtolower($headers->ctype);
+
         // Here we can recognize malformed BODYSTRUCTURE and
         // 1. [@TODO] parse the message in other way to create our own message structure
         // 2. or just show the raw message body.
         // Example of structure for malformed MIME message:
-        // ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 2154 70 NIL NIL NIL)
-        if ($headers->ctype && $headers->ctype != 'text/plain'
-            && $structure[0] == 'text' && $structure[1] == 'plain') {
-            return false;
+        // ("text" "plain" NIL NIL NIL "7bit" 2154 70 NIL NIL NIL)
+        if ($headers->ctype && !is_array($structure[0]) && $headers->ctype != 'text/plain'
+            && strtolower($structure[0].'/'.$structure[1]) == 'text/plain') {
+            // we can handle single-part messages, by simple fix in structure (#1486898)
+            if (preg_match('/^(text|application)\/(.*)/i', $headers->ctype, $m)) {
+                $structure[0] = $m[1];
+                $structure[1] = $m[2];
+            }
+            else
+                return false;
         }
 
         $struct = &$this->_structure_part($structure);

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list