Weird subject processing now cut off correctly
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 28 Feb 2003 21:35:05 +0000 (21:35 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 28 Feb 2003 21:35:05 +0000 (21:35 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4569 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/mailbox_display.php

index 79954364b39ed3b005ae1fa74b6397e14476d271..c30a5ac6c29e649bf09c9f29418bc6f5673632e9 100644 (file)
@@ -466,7 +466,7 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
     mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color); 
     echo '</td></tr></table>';
     $t = elapsed($start);
     mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color); 
     echo '</td></tr></table>';
     $t = elapsed($start);
-    echo("elapsed time = $t seconds\n");
+    //echo("elapsed time = $t seconds\n");
 }
 
 function calc_msort($msgs, $sort) {
 }
 
 function calc_msort($msgs, $sort) {
@@ -1152,22 +1152,26 @@ function processSubject($subject, $threadlevel = 0) {
     if (strlen($subject) <= $trim_at)
         return $subject;
 
     if (strlen($subject) <= $trim_at)
         return $subject;
 
-    $ent_strlen = strlen($subject);
+    $ent_strlen = $orig_len = strlen($subject);
     $trim_val = $trim_at - 5;
     $ent_offset = 0;
     /*
      * see if this is entities-encoded string
      * If so, Iterate through the whole string, find out
      * the real number of characters, and if more
     $trim_val = $trim_at - 5;
     $ent_offset = 0;
     /*
      * see if this is entities-encoded string
      * If so, Iterate through the whole string, find out
      * the real number of characters, and if more
-     * than 55, substr with an updated trim value.
+     * than 55, substr with an updated trim value. 
      */
      */
-
-    while ( (($ent_loc = strpos(substr($subject,0,$trim_val), '&', $ent_offset)) !== false) &&
-            (($ent_loc_end = strpos(substr($subject,0,$trim_val+5), ';', $ent_loc)) !== false) ) {
-        $trim_val   += ($ent_loc_end-$ent_loc)+1;
+    while ((($ent_loc = strpos(substr($subject,$ent_offset-1,$trim_val), '&', $ent_offset)) !== false) &&
+           (($ent_loc_end = strpos(substr($subject,$ent_offset+1,$trim_val+5), ';', $ent_loc)) !== false) ) {
+        $trim_val   += ($ent_loc_end-$ent_loc+1);
         $ent_strlen -= $ent_loc_end-$ent_loc;
         $ent_offset  = $ent_loc_end+1;
     }
         $ent_strlen -= $ent_loc_end-$ent_loc;
         $ent_offset  = $ent_loc_end+1;
     }
+    /* fix cut in the middle special chars */
+    if (strpos($subject,';',$trim_val) < (6+$trim_val) && strpos($subject,'&',$trim_val-4)<$trim_val+1) {
+        $trim_val = strpos($subject,';',$trim_val);
+    }
+
 
     if ($ent_strlen <= $trim_at){
         return $subject;
 
     if ($ent_strlen <= $trim_at){
         return $subject;