r13926 from stable:
authorkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 8 Mar 2010 09:37:07 +0000 (09:37 +0000)
committerkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 8 Mar 2010 09:37:07 +0000 (09:37 +0000)
code in findDisplayEntity expects object, not array. Make findAltenativeEntity
return an object or null consistently.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13927 7612ce4b-ef26-0410-bec9-ea0150e637f0

class/mime/Message.class.php

index fcd86e4..cd49dea 100644 (file)
@@ -987,12 +987,14 @@ class Message {
         if ($this->type0 == 'multipart') {
             if($this->type1 == 'alternative') {
                 $msg = $this->findAlternativeEntity($alt_order);
-                if (count($msg->entities) == 0) {
-                    $entity[] = $msg->entity_id;
-                } else {
-                    $entity = $msg->findDisplayEntity($entity, $alt_order, $strict);
+                if ( ! is_null($msg) ) {
+                    if (count($msg->entities) == 0) {
+                        $entity[] = $msg->entity_id;
+                    } else {
+                        $entity = $msg->findDisplayEntity($entity, $alt_order, $strict);
+                    }
+                    $found = true;
                 }
-                $found = true;
             } else if ($this->type1 == 'related') { /* RFC 2387 */
                 $msgs = $this->findRelatedEntity();
                 foreach ($msgs as $msg) {
@@ -1057,19 +1059,19 @@ class Message {
 
     /**
      * @param array $alt_order
-     * @return array
+     * @return entity
      */
     function findAlternativeEntity($alt_order) {
         /* If we are dealing with alternative parts then we  */
         /* choose the best viewable message supported by SM. */
         $best_view = 0;
-        $entity = array();
+        $entity = null;
         foreach($this->entities as $ent) {
             $type = $ent->header->type0 . '/' . $ent->header->type1;
             if ($type == 'multipart/related') {
                 $type = $ent->header->getParameter('type');
-            // Mozilla bug. Mozilla does not provide the parameter type.
-            if (!$type) $type = 'text/html';
+                // Mozilla bug. Mozilla does not provide the parameter type.
+                if (!$type) $type = 'text/html';
             }
             $altCount = count($alt_order);
             for ($j = $best_view; $j < $altCount; ++$j) {