X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fimap_general.php;h=9333f177fb8755c6ce067fe08ba85b3d611eebe4;hp=e07bbc99590aaf7770f0b22abdcf04d40ca9c6e5;hb=6282af0942232016066870b41fac23f9af4dfe20;hpb=dae7a3c2759ac891830dd90d26dc8e1da3e4432d diff --git a/functions/imap_general.php b/functions/imap_general.php index e07bbc99..9333f177 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -334,35 +334,30 @@ function sqimap_find_email ($string) { /* -* Takes the From: field, and creates a displayable name. -* Luke Ehresman -* becomes: Luke Ehresman -* -* becomes: lkehresman@yahoo.com -*/ + * Takes the From: field, and creates a displayable name. + * Luke Ehresman + * "Luke Ehresman" + * lkehresman@yahoo.com (Luke Ehresman) + * become: Luke Ehresman + * + * 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-1); - $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 - $paren1 - 1); + $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 */