git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2914
7612ce4b-ef26-0410-bec9-
ea0150e637f0
$structure_end = substr($structure, $endprop+2);
$structure = trim(substr($structure,0,$startprop));
}
$structure_end = substr($structure, $endprop+2);
$structure = trim(substr($structure,0,$startprop));
}
/* get type1 */
$pos = strrpos($structure,' ');
/* get type1 */
$pos = strrpos($structure,' ');
+ if ($structure{$pos+1} =='(') $pos++;
+
$type1 = strtolower(substr($structure, $pos+2, (count($structure)-2)));
$type1 = strtolower(substr($structure, $pos+2, (count($structure)-2)));
/* cut off type1 */
if ($pos && $startprop) {
$structure = trim(substr($structure, 0, $pos));
/* cut off type1 */
if ($pos && $startprop) {
$structure = trim(substr($structure, 0, $pos));
* figures out what entity to display and returns the $message object
* for that entity.
*/
* 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;
global $show_html_default;
$found = false;
if ($msg) {
$type = $msg->header->type0.'/'.$msg->header->type1;
$found = false;
if ($msg) {
$type = $msg->header->type0.'/'.$msg->header->type1;
$entity[] = $msg->header->entity_id;
} else {
$found = true;
$entity[] = $msg->header->entity_id;
} else {
$found = true;
- $entity = findDisplayEntity($msg,$textOnly);
+ $entity =findDisplayEntity($msg,$textOnly, $entity);
}
} else if ( $type == 'multipart/related') {
}
} 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' &&
}
} else if ( count($entity) == 0 &&
$msg->header->type0 == 'text' &&
}
$i = 0;
while ( isset($msg->entities[$i]) && count($entity) == 0 && !$found ) {
}
$i = 0;
while ( isset($msg->entities[$i]) && count($entity) == 0 && !$found ) {
- $entity = findDisplayEntity($msg->entities[$i], $textOnly);
+ $entity = findDisplayEntity($msg->entities[$i], $textOnly, $entity);
$alt_order = array ('text/plain');
}
$best_view = 0;
$alt_order = array ('text/plain');
}
$best_view = 0;
$k = 0;
for ($i = 0; $i < count($message->entities); $i ++) {
$type = $message->entities[$i]->header->type0.'/'.$message->entities[$i]->header->type1;
$k = 0;
for ($i = 0; $i < count($message->entities); $i ++) {
$type = $message->entities[$i]->header->type0.'/'.$message->entities[$i]->header->type1;
for ($j = $k; $j < count($alt_order); $j++) {
if ($alt_order[$j] == $type && $j > $best_view) {
$best_view = $j;
for ($j = $k; $j < count($alt_order); $j++) {
if ($alt_order[$j] == $type && $j > $best_view) {
$best_view = $j;
- return $message->entities[$best_view];
+ return $message->entities[$ent_id];
}
function findRelatedEntity ($message) {
}
function findRelatedEntity ($message) {
for ($i = 0; $i < count($message->entities); $i ++) {
$type = $message->entities[$i]->header->type0.'/'.$message->entities[$i]->header->type1;
if ($message->header->type == $type) {
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];
// 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.
// 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;
$show_html_default, $has_unsafe_images, $view_unsafe_images, $sort;
$has_unsafe_images = 0;
} else {
translateText($body, $wrap_at, $body_message->header->charset);
}
} else {
translateText($body, $wrap_at, $body_message->header->charset);
}
$body .= "<CENTER><SMALL><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$ent_num&mailbox=$urlmailbox&showHeaders=1\">". _("Download this as a file") ."</A></SMALL></CENTER><BR>";
if ($has_unsafe_images) {
if ($view_unsafe_images) {
$body .= "<CENTER><SMALL><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$ent_num&mailbox=$urlmailbox&showHeaders=1\">". _("Download this as a file") ."</A></SMALL></CENTER><BR>";
if ($has_unsafe_images) {
if ($view_unsafe_images) {