address parsing with encoded personal names
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 7 Mar 2003 22:12:51 +0000 (22:12 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 7 Mar 2003 22:12:51 +0000 (22:12 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4614 7612ce4b-ef26-0410-bec9-ea0150e637f0

class/mime/AddressStructure.class.php
class/mime/Rfc822Header.class.php

index 85939f9..91e04e2 100644 (file)
@@ -25,7 +25,7 @@ class AddressStructure {
                                   : $this->mailbox);
             $personal = trim($this->personal);
             $is_encoded = false;
-            if (preg_match('/^(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/Ui',$personal,$reg)) {
+            if (preg_match('/(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/Ui',$personal,$reg)) {
                 $is_encoded = true;
             }
             if ($personal) {
index 7b37521..1f18f2b 100644 (file)
@@ -260,8 +260,9 @@ class Rfc822Header {
                 if (preg_match('/^(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/Ui',substr($address,$pos),$reg)) {
                     $name .= $reg[1];
                     $pos += strlen($reg[1]);
+                } else {
+                    ++$pos;
                 }
-                ++$pos;
                 $addr_start = $pos;
                 $is_encoded = true;
                 break;
@@ -460,7 +461,11 @@ class Rfc822Header {
         } else if ($name == '') {
             $name = trim(substr($address, 0, $addr_start));
         }
-        if (!$name && $comment) $name = $comment;
+        if (!$name && $comment) {
+            $name = $comment;
+        } else if ($name && $comment) {
+            $name = $name .' ('.$comment.')';
+        }
         $at = strpos($addr, '@');
         $addr_structure = new AddressStructure();
         $addr_structure->group = $group;