Bug #9216: Fix header encoding on compose
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 3 Sep 2010 20:07:45 +0000 (14:07 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 3 Sep 2010 20:07:45 +0000 (14:07 -0600)
Overzealous optimization - there is no away around the fact that we need
to call parseAddressList() twice due to the fact that the first use
needs to be done before we encode/validate the email string.

imp/lib/Compose.php

index 37ffd8d..365ddfe 100644 (file)
@@ -784,16 +784,6 @@ class IMP_Compose
     protected function _prepSendMessage($email, $headers = null,
                                         $message = null)
     {
-        /* Validate the recipient addresses. */
-        try {
-            $alist = Horde_Mime_Address::parseAddressList($email, array(
-                'defserver' => $_SESSION['imp']['maildomain'],
-                'validate' => true
-            ));
-        } catch (Horde_Mime_Exception $e) {
-            throw new IMP_Compose_Exception($e);
-        }
-
         $timelimit = $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_timelimit');
         if ($timelimit !== true) {
             $sentmail = $GLOBALS['injector']->getInstance('IMP_Sentmail');
@@ -808,7 +798,7 @@ class IMP_Compose
                 $recipients = 0;
             }
 
-            foreach ($alist as $address) {
+            foreach (Horde_Mime_Address::parseAddressList($email) as $address) {
                 $recipients += isset($address['grounpname'])
                     ? count($address['addresses'])
                     : 1;
@@ -834,6 +824,12 @@ class IMP_Compose
         /* Properly encode the addresses we're sending to. */
         try {
             $email = Horde_Mime::encodeAddress($email, is_null($message) ? $GLOBALS['registry']->getCharset() : $message->getHeaderCharset(), $_SESSION['imp']['maildomain']);
+
+            /* Validate the recipient addresses. */
+            Horde_Mime_Address::parseAddressList($email, array(
+                'defserver' => $_SESSION['imp']['maildomain'],
+                'validate' => true
+            ));
         } catch (Horde_Mime_Exception $e) {
             throw new IMP_Compose_Exception($e);
         }