fixing a problem regarding the viewing of mails created by MSExchange that seem to contain invalid chars in BASE64 encoded string AND invalid encoding for UTF8

This commit is contained in:
Klaus Leithoff 2009-11-10 10:27:58 +00:00
parent 3a5e270948
commit 781048414b
2 changed files with 5 additions and 3 deletions

View File

@ -376,8 +376,8 @@
switch ($_encoding)
{
case 'BASE64':
// use imap_base64 to decode
return imap_base64($_mimeMessage);
// use imap_base64 to decode, not any longer, as it is strict, and fails if it encounters invalid chars
return base64_decode($_mimeMessage); //imap_base64($_mimeMessage);
break;
case 'QUOTED-PRINTABLE':
// use imap_qprint to decode

View File

@ -1038,9 +1038,11 @@
if($singleBodyPart['mimeType'] == 'text/plain')
{
$newBody = $singleBodyPart['body'];
//$newBody = $singleBodyPart['body'];
$newBody = @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper($this->displayCharset));
// if empty and charset is utf8 try sanitizing the string in question
if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper($this->displayCharset));
// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'],ENT_QUOTES);
#$newBody = $this->bofelamimail->wordwrap($newBody, 90, "\n");