Fix parsing mailto: URLs in HTML viewer
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 23 Jul 2010 15:58:23 +0000 (09:58 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 23 Jul 2010 15:58:23 +0000 (09:58 -0600)
imp/lib/IMP.php
imp/lib/Mime/Viewer/Html.php

index 7e15775..e269a97 100644 (file)
@@ -297,13 +297,9 @@ class IMP
 
     /**
      * Checks for To:, Subject:, Cc:, and other compose window arguments and
-     * pass back either a URI fragment or an associative array with any of
-     * them which are present.
+     * pass back an associative array of those that are present.
      *
-     * @param string $format  Either 'uri' or 'array'.
-     *
-     * @return string  A URI fragment or an associative array with any compose
-     *                 arguments present.
+     * @return string  An associative array with compose arguments.
      */
     static public function getComposeArgs()
     {
@@ -316,7 +312,18 @@ class IMP
             }
         }
 
-        /* Decode mailto: URLs. */
+        return self::_decodeMailto($args);
+    }
+
+    /**
+     * Checks for mailto: prefix in the To field.
+     *
+     * @param array $args  A list of compose arguments.
+     *
+     * @return array  The array with the To: argument stripped of mailto:.
+     */
+    static protected function _decodeMailto($args)
+    {
         if (isset($args['to']) && (strpos($args['to'], 'mailto:') === 0)) {
             $mailto = @parse_url($args['to']);
             if (is_array($mailto)) {
@@ -376,6 +383,8 @@ class IMP
             }
         }
 
+        $args = self::_decodeMailto($args);
+
         /* Merge the two argument arrays. */
         return (is_array($extra) && !empty($extra))
             ? array_merge($args, $extra)
index 364303b..d528951 100644 (file)
@@ -301,8 +301,9 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
                         if (!$child->hasAttribute('target') &&
                             $child->hasAttribute('href')) {
                             $url = parse_url($child->getAttribute('href'));
-                            if (empty($url['fragment']) &&
-                                ($url['scheme'] != 'mailto:')) {
+                            if ($url['scheme'] == 'mailto') {
+                                $child->setAttribute('href', IMP::composeLink($child->getAttribute('href')));
+                            } elseif (empty($url['fragment'])) {
                                 $child->setAttribute('target', $this->_tmp['target']);
                             }
                         }