Fix for addressbook entries containing multiple email addresses (group)
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 8 Apr 2003 16:48:33 +0000 (16:48 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 8 Apr 2003 16:48:33 +0000 (16:48 +0000)
This should solve the send error after compose.

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

class/mime/Rfc822Header.class.php

index 1326c6c538a353d7bbf2b8afbabe2aa624f472a6..e6562fe58927e5f8c343191341981f9e9faf317a 100644 (file)
@@ -332,6 +332,7 @@ class Rfc822Header {
                 }
                 $is_encoded = false;
                 $addr_structure->group = $group;
+                $grouplookup = false;
                 if ($at) {
                     $addr_structure->mailbox = substr($addr, 0, $at);
                     $addr_structure->host = substr($addr, $at+1);
@@ -340,17 +341,22 @@ class Rfc822Header {
                     if ($lookup) {
                         $aAddr = call_user_func_array($lookup,array($addr));
                         if (isset($aAddr['email'])) {
-                            $at = strpos($aAddr['email'], '@');
-                            $addr_structure->mailbox = substr($aAddr['email'], 0, $at);
-                            $addr_structure->host = substr($aAddr['email'], $at+1);
-                            if (isset($aAddr['name'])) {
-                                $addr_structure->personal = $aAddr['name'];
+                            if (strpos($aAddr['email'],',')) {
+                                $grouplookup = true;
+                                $addr_ar = $this->parseAddress($aAddr['email'], $ar, $addr_ar, $group, $host,$lookup);
                             } else {
-                                $addr_structure->personal = encodeHeader($addr);
+                                $at = strpos($aAddr['email'], '@');
+                                $addr_structure->mailbox = substr($aAddr['email'], 0, $at);
+                                $addr_structure->host = substr($aAddr['email'], $at+1);
+                                if (isset($aAddr['name'])) {
+                                    $addr_structure->personal = $aAddr['name'];
+                                } else {
+                                    $addr_structure->personal = encodeHeader($addr);
+                                }
                             }
                         }
                     }
-                    if (!$addr_structure->mailbox) {
+                    if (!$grouplookup && !$addr_structure->mailbox) {
                         $addr_structure->mailbox = trim($addr);
                         if ($host) {
                             $addr_structure->host = $host;
@@ -362,13 +368,15 @@ class Rfc822Header {
                 $pos = 0;
                 $name = '';
                 $addr = '';
-                $addr_ar[] = $addr_structure;
+                if (!$grouplookup) {
+                    $addr_ar[] = $addr_structure;
+                }
                 break;
             case ':':  /* process the group addresses */
                 /* group marker */
                 $group = substr($address, 0, $pos);
                 $address = substr($address, $pos+1);
-                $result = $this->parseAddress($address, $ar, $addr_ar, $group);
+                $result = $this->parseAddress($address, $ar, $addr_ar, $group, $lookup);
                 $addr_ar = $result[0];
                 $pos = $result[1];
                 $address = substr($address, $pos++);
@@ -477,13 +485,17 @@ class Rfc822Header {
             if ($lookup) {
                 $aAddr = call_user_func_array($lookup,array($addr));
                 if (isset($aAddr['email'])) {
-                    $at = strpos($aAddr['email'], '@');
-                    $addr_structure->mailbox = substr($aAddr['email'], 0, $at);
-                    $addr_structure->host = substr($aAddr['email'], $at+1);
-                    if (isset($aAddr['name']) && $aAddr['name']) {
-                        $name = $aAddr['name'];
+                    if (strpos($aAddr['email'],',')) {
+                        return $this->parseAddress($aAddr['email'], $ar, $addr_ar, $group, $host,$lookup);
                     } else {
-                        $name = $addr;
+                        $at = strpos($aAddr['email'], '@');
+                        $addr_structure->mailbox = substr($aAddr['email'], 0, $at);
+                        $addr_structure->host = substr($aAddr['email'], $at+1);
+                        if (isset($aAddr['name']) && $aAddr['name']) {
+                            $name = $aAddr['name'];
+                        } else {
+                            $name = $addr;
+                        }
                     }
                 }
             }