From 366ca052007a515a0ff65b1bd15115b4cba88b33 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Fri, 30 Aug 2024 00:39:00 +0200 Subject: [PATCH] Bugfix: application/pgp-encrypted attachments not listed --- .../libraries/MailSo/Imap/BodyStructure.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php index f9adf6497..bf3dc8981 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php @@ -172,9 +172,10 @@ class BodyStructure implements \JsonSerializable ); } - public function IsAttachment() : bool + protected function IsAttachment(/*BodyStructure*/ $oParent) : bool { - return 'application/pgp-encrypted' !== $this->sContentType +// return 'application/pgp-encrypted' !== $this->sContentType + return (!$oParent || !$oParent->isPgpEncrypted()) && ( 'attachment' === $this->sDisposition || ( !\str_starts_with($this->sContentType, 'multipart/') @@ -194,8 +195,8 @@ class BodyStructure implements \JsonSerializable { $aParts = []; - $gParts = $this->SearchByCallback(function ($oItem) { - return $oItem->isText() && !$oItem->IsAttachment(); + $gParts = $this->SearchByCallback(function ($oItem, $oParent) { + return $oItem->isText() && !$oItem->IsAttachment($oParent); }); foreach ($gParts as $oPart) { $aParts[] = $oPart; @@ -232,13 +233,13 @@ class BodyStructure implements \JsonSerializable public function SearchCharset() : string { - $gParts = $this->SearchByCallback(function ($oPart) { - return $oPart->Charset() && $oPart->isText() && !$oPart->IsAttachment(); + $gParts = $this->SearchByCallback(function ($oPart, $oParent) { + return $oPart->Charset() && $oPart->isText() && !$oPart->IsAttachment($oParent); }); if (!$gParts->valid()) { - $gParts = $this->SearchByCallback(function ($oPart) { - return $oPart->Charset() && $oPart->IsAttachment(); + $gParts = $this->SearchByCallback(function ($oPart, $oParent) { + return $oPart->Charset() && $oPart->IsAttachment($oParent); }); } @@ -259,7 +260,7 @@ class BodyStructure implements \JsonSerializable { return $this->SearchByCallback(function ($oItem, $oParent) { // return $oItem->IsAttachment(); - return $oItem->IsAttachment() && (!$oParent || !$oParent->isPgpEncrypted()); + return $oItem->IsAttachment($oParent) && (!$oParent || !$oParent->isPgpEncrypted()); }); }