fixing the fix: forwarded messages containing just a PDF were now unreadable again

This commit is contained in:
ralf 2024-03-08 14:41:47 +02:00
parent f9f6700f8a
commit 1535887d70

View File

@ -6230,7 +6230,7 @@ class Mail
* Some broken clients e.g. SAP Netweaver sends mails containing only a base64 decoded PDF, but set NO Content-Transfer-Type: base64.
*
* @param Horde_Mime_Part $part
* @return Horde_Mime_Part
* @return bool true: part needed fixing AND is base64 encoded, false: no need to fix the part
*/
public static function fixBinaryPart(Horde_Mime_Part $part)
{
@ -6241,8 +6241,9 @@ class Mail
unserialize($part->serialize())[9] !== 'base64')
{
$part->setTransferEncoding('binary', ['send' => true]);
return true;
}
return $part;
return false;
}
/**
@ -6264,12 +6265,12 @@ class Mail
$fetchAsBinary = true;
if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false;
self::fixBinaryPart($part);
$need_base64 = self::fixBinaryPart($part);
// we need to set content on structure to decode transfer encoding
$part->setContents(
$this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary),
array('encoding' => !$fetchAsBinary&&!$encoding?'8bit':$encoding));
array('encoding' => $need_base64 ? 'base64' : (!$fetchAsBinary&&!$encoding?'8bit':$encoding)));
return $part;
}