This commit is contained in:
the-djmaze 2022-01-28 16:43:50 +01:00
parent f8da8b5135
commit 58d02fa2e7

View file

@ -218,27 +218,30 @@ class BodyStructure
public function GetHtmlAndPlainParts() : array public function GetHtmlAndPlainParts() : array
{ {
$aParts = $this->SearchByCallback(function ($oItem) { $aParts = [];
$gParts = $this->SearchByCallback(function ($oItem) {
return ('text/html' === $oItem->sContentType || 'text/plain' === $oItem->sContentType) return ('text/html' === $oItem->sContentType || 'text/plain' === $oItem->sContentType)
&& !$oItem->IsAttachBodyPart(); && !$oItem->IsAttachBodyPart();
}); });
foreach ($gParts as $oPart) {
if ($aParts->valid()) { $aParts[] = $oPart;
return \array_merge([$aParts->current()], \iterator_to_array($aParts));
} }
/** /**
* No text found, is it encrypted? * No text found, is it encrypted?
* If so, just return that. * If so, just return that.
*/ */
$gEncryptedParts = $this->SearchByContentType('multipart/encrypted'); if (!$aParts) {
foreach ($gEncryptedParts as $oPart) { $gEncryptedParts = $this->SearchByContentType('multipart/encrypted');
if ($oPart->IsPgpEncrypted() && $oPart->SubParts()[1]->IsInline()) { foreach ($gEncryptedParts as $oPart) {
return array($oPart->SubParts()[1]); if ($oPart->IsPgpEncrypted() && $oPart->SubParts()[1]->IsInline()) {
return array($oPart->SubParts()[1]);
}
} }
} }
return []; return $aParts;
} }
public function SearchCharset() : string public function SearchCharset() : string