One last ditch effort to get a good email address for looking up gravatars.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 10 Dec 2010 20:35:23 +0000 (15:35 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 10 Dec 2010 20:37:45 +0000 (15:37 -0500)
At least in the case of git, the email address returned isn't properly quoted
so parseAddressList() fails.

chora/lib/Chora.php

index 8f6bb9d..24276c6 100644 (file)
@@ -442,7 +442,7 @@ class Chora
         return htmlspecialchars($name);
     }
 
-    public function getAuthorEmail($name)
+    static public function getAuthorEmail($name)
     {
         try {
             $users = $GLOBALS['VC']->getUsers($GLOBALS['conf']['paths']['cvsusers']);
@@ -457,11 +457,18 @@ class Chora
             if (count($results)) {
                 return $results[0]->mailbox . '@' . $results[0]->host;
             }
-        } catch (Horde_Mail_Exception $e) {}
+        } catch (Horde_Mail_Exception $e) {
+            try {
+                if (preg_match('|<(\S+)>|', $name, $matches)) {
+                    return self::getAuthorEmail($matches[1]);
+                }
+            } catch (Horde_Mail_Exception $e){}
+        }
 
         return $name;
     }
 
+
     /**
      * Return formatted date information.
      *
@@ -496,4 +503,5 @@ class Chora
             ? $log
             : preg_replace($GLOBALS['conf']['tickets']['regexp'], $GLOBALS['conf']['tickets']['replacement'], $log);
     }
+
 }