Fix for 636577.
[squirrelmail.git] / functions / mailbox_display.php
index 1b002ec461013bd16a23d4ade40372c82b3331fb..4174bbc1b2fca7493db56925834fc4035aae81d8 100644 (file)
@@ -76,7 +76,7 @@ function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
        $senderName = sqimap_find_displayable_name($msg['FROM']);
     }
 
-    $subject = processSubject($msg['SUBJECT']);
+    $subject = processSubject($msg['SUBJECT'], $indent_array[$msg['ID']]);
 
     echo html_tag( 'tr','','','','VALIGN="top"') . "\n";
 
@@ -155,7 +155,7 @@ function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
                 break;
             case 2: /* from */
                 echo html_tag( 'td',
-                               $italic . $bold . $flag . $fontstr . $senderName .
+                               $italic . $bold . $flag . $fontstr . htmlentities($senderName) .
                                $fontstr_end . $flag_end . $bold_end . $italic_end,
                                'left',
                                $hlt_color );
@@ -175,7 +175,7 @@ function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
             case 4: /* subject */
                 $td_str = $bold;
                 if ($thread_sort_messages == 1) {
-                    if (isset($indent_array[$msg["ID"]])) {
+                    if (isset($indent_array[$msg['ID']])) {
                         $td_str .= str_repeat("    ",$indent_array[$msg['ID']]);
                     }
                 }
@@ -1168,18 +1168,24 @@ function get_paginator_str($box, $start_msg, $end_msg, $num_msgs,
     return ($result);
 }
 
-function processSubject($subject) {
+function processSubject($subject, $threadlevel = 0) {
     global $languages, $squirrelmail_language;
     /* Shouldn't ever happen -- caught too many times in the IMAP functions */
     if ($subject == '')
         return _("(no subject)");
 
-    if (strlen($subject) <= 55)
+    $trim_at = 55;
+
+    /* if this is threaded, substract two chars per indentlevel */
+    if($threadlevel > 0 && $threadlevel <= 10)
+        $trim_at -= (2*$threadlevel);
+
+    if (strlen($subject) <= $trim_at)
         return $subject;
 
     $ent_strlen = strlen($subject);
-    $trim_val=50;
-    $ent_offset=0;
+    $trim_val = $trim_at - 5;
+    $ent_offset = 0;
     /*
      * see if this is entities-encoded string
      * If so, Iterate through the whole string, find out
@@ -1193,7 +1199,7 @@ function processSubject($subject) {
         $ent_offset  = $ent_loc_end+1;
     }
 
-    if ($ent_strlen <= 55){
+    if ($ent_strlen <= $trim_at){
         return $subject;
     }
 
@@ -1241,16 +1247,15 @@ function getEndMessage($start_msg, $show_num, $num_msgs) {
 }
 
 function handleAsSent($mailbox) {
-    global $sent_folder, $draft_folder, $handleAsSent_result;
-
+    global $handleAsSent_result;
     /* First check if this is the sent or draft folder. */
-    $handleAsSent_result = (($mailbox == $sent_folder)
-                             || ($mailbox == $draft_folder));
+    $handleAsSent_result = isSentMailbox($mailbox) || isDraftMailbox($mailbox);
 
     /* Then check the result of the handleAsSent hook. */
     do_hook('check_handleAsSent_result', $mailbox);
 
     /* And return the result. */
-    return ($handleAsSent_result);
+    return $handleAsSent_result;
 }
 ?>