Minor fixes in parseAddress and limit the returned results to 1 address
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 23 May 2003 11:51:05 +0000 (11:51 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 23 May 2003 11:51:05 +0000 (11:51 +0000)
(performance) in case we are displaying the sent folder

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

functions/imap_general.php
functions/mailbox_display.php

index 16f84a2..8d58c48 100755 (executable)
@@ -432,30 +432,33 @@ function sqimap_get_num_messages ($imap_stream, $mailbox) {
 }
 
 
-function parseAddress($address, $max=0, $addr_ar = array(), $group = '', $host='') {
+function parseAddress($address, $max=0, $addr_ar = array(), $group = '', $host='', $limit=0) {
     $pos = 0;
     $j = strlen($address);
     $personal = '';
     $addr = '';
     $comment = '';
-    if ($max && $max = count($addr_ar)) {
+    if ($max && $max == count($addr_ar)) {
         return $addr_ar;
     }
     while ($pos < $j) {
-        if ($max && $max = count($addr_ar)) {
+        if ($max && $max == count($addr_ar)) {
             return $addr_ar;
         }
         $char = $address{$pos};
         switch ($char) {
             case '=':
+               /* check if it is an encoded string */
                 if (preg_match('/^(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/Ui',substr($address,$pos),$reg)) {
+                   /* add stringpart before the encoded string to the personal var */
                    if (!$personal) {
                        $personal = substr($address,0,$pos);
                    }
                     $personal .= $reg[1];
-                    $pos += strlen($personal);
-                }
-                ++$pos;
+                   $pos += strlen($reg[1]);
+                } else {
+                   ++$pos;
+               }
                 break;
             case '"': /* get the personal name */
                 ++$pos;
@@ -498,6 +501,12 @@ function parseAddress($address, $max=0, $addr_ar = array(), $group = '', $host='
                 $j = strlen($address);
                 $pos = $addr_start + 1;
                 break;
+            case ';': /* we reached a non rfc2822 compliant delimiter */
+                if ($group) {
+                    $address = substr($address, 0, $pos - 1);
+                   ++$pos;
+                   break;
+                }
             case ',':  /* we reached a delimiter */
                 if ($addr == '') {
                     $addr = substr($address, 0, $pos);
@@ -524,12 +533,6 @@ function parseAddress($address, $max=0, $addr_ar = array(), $group = '', $host='
                 $j = strlen($address);
                 $group = '';
                 break;
-            case ';':
-                if ($group) {
-                    $address = substr($address, 0, $pos - 1);
-                }
-                ++$pos;
-                break;
             default:
                 ++$pos;
                 break;
index 30d36f7..426609e 100644 (file)
@@ -73,7 +73,7 @@ function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
     if (handleAsSent($mailbox)) {
        $msg['FROM'] = $msg['TO'];
     }
-    $msg['FROM'] = parseAddress($msg['FROM']);
+    $msg['FROM'] = parseAddress($msg['FROM'],1);
     
        /*
         * This is done in case you're looking into Sent folders,