From 008989da27741b9839b7e99e72f7979ee16ee28c Mon Sep 17 00:00:00 2001 From: stekkel Date: Thu, 30 May 2002 19:39:59 +0000 Subject: [PATCH] small fixes git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2914 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/mime.php | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/functions/mime.php b/functions/mime.php index 2a56b561..202028ee 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -128,11 +128,11 @@ function mime_parse_structure ($structure, $ent_id) { $structure_end = substr($structure, $endprop+2); $structure = trim(substr($structure,0,$startprop)); } - /* get type1 */ $pos = strrpos($structure,' '); + if ($structure{$pos+1} =='(') $pos++; + $type1 = strtolower(substr($structure, $pos+2, (count($structure)-2))); - /* cut off type1 */ if ($pos && $startprop) { $structure = trim(substr($structure, 0, $pos)); @@ -617,10 +617,9 @@ function getEntity ($message, $ent_id) { * figures out what entity to display and returns the $message object * for that entity. */ -function findDisplayEntity ($msg, $textOnly = 1) { +function findDisplayEntity ($msg, $textOnly = 1, $entity = array() ) { global $show_html_default; - $entity = array(); $found = false; if ($msg) { $type = $msg->header->type0.'/'.$msg->header->type1; @@ -630,15 +629,18 @@ function findDisplayEntity ($msg, $textOnly = 1) { $entity[] = $msg->header->entity_id; } else { $found = true; - $entity = findDisplayEntity($msg,$textOnly); + $entity =findDisplayEntity($msg,$textOnly, $entity); } } else if ( $type == 'multipart/related') { - $msg = findRelatedEntity($msg); - if (count($msg->entities) == 0) { - $entity[] = $msg->header->entity_id; - } else { - $found = true; - $entity = findDisplayEntity($msg,$textOnly); + $msgs = findRelatedEntity($msg); + for ($i = 0; $i < count($msgs); $i++) { + $msg = $msgs[$i]; + if (count($msg->entities) == 0) { + $entity[] = $msg->header->entity_id; + } else { + $found = true; + $entity =findDisplayEntity($msg,$textOnly, $entity); + } } } else if ( count($entity) == 0 && $msg->header->type0 == 'text' && @@ -651,7 +653,7 @@ function findDisplayEntity ($msg, $textOnly = 1) { } $i = 0; while ( isset($msg->entities[$i]) && count($entity) == 0 && !$found ) { - $entity = findDisplayEntity($msg->entities[$i], $textOnly); + $entity = findDisplayEntity($msg->entities[$i], $textOnly, $entity); $i++; } } @@ -696,6 +698,7 @@ function findAlternativeEntity ($message) { $alt_order = array ('text/plain'); } $best_view = 0; + $ent_id = 0; $k = 0; for ($i = 0; $i < count($message->entities); $i ++) { $type = $message->entities[$i]->header->type0.'/'.$message->entities[$i]->header->type1; @@ -705,21 +708,23 @@ function findAlternativeEntity ($message) { for ($j = $k; $j < count($alt_order); $j++) { if ($alt_order[$j] == $type && $j > $best_view) { $best_view = $j; + $ent_id = $i; $k = $j; } } } - return $message->entities[$best_view]; + return $message->entities[$ent_id]; } function findRelatedEntity ($message) { + $msgs = array(); for ($i = 0; $i < count($message->entities); $i ++) { $type = $message->entities[$i]->header->type0.'/'.$message->entities[$i]->header->type1; if ($message->header->type == $type) { - return $message->entities[$i]; + $msgs[] = $message->entities[$i]; } } - return $message->entities[0]; + return $msgs; } /* @@ -817,7 +822,7 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num) { // this if statement checks for the entity to show as the // primary message. To add more of them, just put them in the // order that is their priority. - global $startMessage, $username, $key, $imapServerAddress, $imapPort, $body, + global $startMessage, $username, $key, $imapServerAddress, $imapPort, $show_html_default, $has_unsafe_images, $view_unsafe_images, $sort; $has_unsafe_images = 0; @@ -846,7 +851,6 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num) { } else { translateText($body, $wrap_at, $body_message->header->charset); } - $body .= "
". _("Download this as a file") ."

"; if ($has_unsafe_images) { if ($view_unsafe_images) { -- 2.25.1