diff --git a/include/class.format.php b/include/class.format.php index 000d771bb756b35d5f8982286500d4fbd6a0f061..8d302aaa858e1e6032ab15bfe0c461669e17744b 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -73,9 +73,10 @@ class Format { $str.= Format::encode($part->text, $part->charset, $encoding); $text = $str; - } elseif(function_exists('iconv_mime_decode')) { + } elseif($text[0] == '=' && function_exists('iconv_mime_decode')) { $text = iconv_mime_decode($text, 0, $encoding); - } elseif(!strcasecmp($encoding, 'utf-8') && function_exists('imap_utf8')) { + } elseif(!strcasecmp($encoding, 'utf-8') + && function_exists('imap_utf8')) { $text = imap_utf8($text); } diff --git a/include/class.mailparse.php b/include/class.mailparse.php index 9c96403e5860b45cfcbd070b7236022c0caf1127..fda03365826ce8b6a124e4bb1a5bc9d56bfc6865 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -513,12 +513,18 @@ class Mail_Parse { $parsed = Mail_RFC822::parseAddressList($address, null, null,false); - if(PEAR::isError($parsed)) + if (PEAR::isError($parsed)) return array(); + // Decode name and mailbox foreach ($parsed as $p) { $p->personal = Format::mimedecode($p->personal, $this->charset); + // Some mail clients may send ISO-8859-1 strings without proper encoding. + // Also, handle the more sane case where the mailbox is properly encoded + // against RFC2047 + $p->mailbox = Format::mimedecode($p->mailbox, $this->charset); } + return $parsed; }