Moving help files from pl to pl_PL
[squirrelmail.git] / functions / imap_general.php
index 391a5a9c9c0cf6bd7ea167d1fe14c8ae98d39799..9333f177fb8755c6ce067fe08ba85b3d611eebe4 100755 (executable)
@@ -334,35 +334,30 @@ function sqimap_find_email ($string) {
 
 
 /*
-*  Takes the From: field, and creates a displayable name.
-*    Luke Ehresman <lkehresman@yahoo.com>
-*           becomes:   Luke Ehresman
-*    <lkehresman@yahoo.com>
-*           becomes:   lkehresman@yahoo.com
-*/
+ *  Takes the From: field, and creates a displayable name.
+ *    Luke Ehresman   <lkehresman@yahoo.com>
+ *    "Luke Ehresman" <lkehresman@yahoo.com>
+ *    lkehresman@yahoo.com (Luke Ehresman)
+ *           become:   Luke Ehresman
+ *    <lkehresman@yahoo.com>
+ *           becomes:   lkehresman@yahoo.com
+ */
 function sqimap_find_displayable_name ($string) {
-    $string = ' '.trim($string);
-    $orig_string = $string;
-    if (($angle1=strpos($string, '<')) && strpos($string, '>')) {
-        if ($angle1 == 1) {
-            $string = sqimap_find_email($string);
-        } else {
-            $string = trim($string);
-            $string = substr($string, 0, $angle1);
-            $string = ereg_replace ('"', '', $string);
-        }
-        
-        if (trim($string) == '') {
-            $string = sqimap_find_email($orig_string);
-        }
-    } else if ( ($paren1=strpos($string, '('))
-                && ($paren2=strpos($string, ')'))) {
-        $string = substr($string, $paren1 + 1, $paren2 - $fn_start);
+    $string = trim($string);
+    
+    if ( ereg('^(.+)<.*>', $string, $regs) ) {
+        $string = ereg_replace ('"', '', $regs[1] );
+    }
+    elseif ( ereg('\((.*)\)', $string, $regs) ) {
+        $string = $regs[1];
+    }
+    else {
+        $string = sqimap_find_email($string);
     }
-    return $string;
-}
-
 
+    return trim($string);
+}
+    
 /*
 *  Returns the number of unseen messages in this folder
 */