Reset $msg on each iteration, otherwise a message with eg no subject
[squirrelmail.git] / functions / imap_messages.php
index cdcb1c208b4caa8bbb2c86e67b9e88c89a1fbb59..5afd30303748093788828c281ad42c7d80e20386 100755 (executable)
@@ -534,11 +534,7 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $show_num=false,
     $messages = array();
     $read_list = array();
 
-    if (array_search('UID',$aFetchItems,true) !== false) {
-        $bUidFetch = false;
-    } else {
-        $bUidFetch = true;
-    }
+    $bUidFetch = ! in_array('UID', $aFetchItems, true);
 
     /* Get the small headers for each message in $msg_list */
     if ($show_num != '999999' && $show_num != '*' ) {
@@ -578,6 +574,7 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $show_num=false,
     $i = 0;
 
     foreach ($read_list as $r) {
+        $msg = array();
         // use unset because we do isset below
         $read = implode('',$r);
 
@@ -683,9 +680,12 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $show_num=false,
                                     $type = substr($type, 0, $pos);
                                 }
                                 $type = explode("/", $type);
-                                if(!is_array($type)) {
+                                if(!is_array($type) || count($type) < 2) {
                                     $msg['TYPE0'] = 'text';
                                     $msg['TYPE1'] = 'plain';
+                                } else {
+                                    $msg['TYPE0'] = strtolower($type[0]);
+                                    $msg['TYPE1'] = strtolower($type[1]);
                                 }
                                 break;
                             case 'received':