Hides valid inline parts from attachments section #180

This commit is contained in:
the-djmaze 2022-01-10 15:19:25 +01:00
parent 0e2e44a269
commit dd6779b1a8

View file

@ -203,9 +203,9 @@ trait Response
if ('Message' === $sParent) if ('Message' === $sParent)
{ {
$bHasExternals = false; $bHasExternals = false;
$mFoundCIDs = array(); $aFoundCIDs = array();
$aContentLocationUrls = array(); $aContentLocationUrls = array();
$mFoundContentLocationUrls = array(); $aFoundContentLocationUrls = array();
$oAttachments = /* @var \MailSo\Mail\AttachmentCollection */ $mResponse->Attachments(); $oAttachments = /* @var \MailSo\Mail\AttachmentCollection */ $mResponse->Attachments();
if ($oAttachments && 0 < $oAttachments->count()) if ($oAttachments && 0 < $oAttachments->count())
@ -253,7 +253,7 @@ trait Response
}, $sHtml); }, $sHtml);
$mResult['Html'] = \strlen($sHtml) ? \MailSo\Base\HtmlUtils::ClearHtml( $mResult['Html'] = \strlen($sHtml) ? \MailSo\Base\HtmlUtils::ClearHtml(
$sHtml, $bHasExternals, $mFoundCIDs, $aContentLocationUrls, $mFoundContentLocationUrls, $sHtml, $bHasExternals, $aFoundCIDs, $aContentLocationUrls, $aFoundContentLocationUrls,
$fAdditionalExternalFilter, !!$this->Config()->Get('labs', 'try_to_detect_hidden_images', false) $fAdditionalExternalFilter, !!$this->Config()->Get('labs', 'try_to_detect_hidden_images', false)
) : ''; ) : '';
@ -270,16 +270,14 @@ trait Response
unset($sHtml, $sPlain); unset($sHtml, $sPlain);
$mResult['HasExternals'] = $bHasExternals; $mResult['HasExternals'] = $bHasExternals;
$mResult['HasInternals'] = (\is_array($mFoundCIDs) && \count($mFoundCIDs)) || $mResult['HasInternals'] = \count($aFoundCIDs) || \count($aFoundContentLocationUrls);
(\is_array($mFoundContentLocationUrls) && \count($mFoundContentLocationUrls));
$mResult['Attachments'] = $this->responseObject($oAttachments, $sParent, $aParameters); // $mResult['FoundCIDs'] = $aFoundCIDs;
/*
// $mResult['FoundCIDs'] = $mFoundCIDs;
$mResult['Attachments'] = $this->responseObject($oAttachments, $sParent, \array_merge($aParameters, array( $mResult['Attachments'] = $this->responseObject($oAttachments, $sParent, \array_merge($aParameters, array(
'FoundCIDs' => $mFoundCIDs, 'FoundCIDs' => $aFoundCIDs,
'FoundContentLocationUrls' => $mFoundContentLocationUrls 'FoundContentLocationUrls' => $aFoundContentLocationUrls
))); )));
*/
$mResult['ReadReceipt'] = $mResponse->ReadReceipt(); $mResult['ReadReceipt'] = $mResponse->ReadReceipt();
if (\strlen($mResult['ReadReceipt']) && !\in_array('$forwarded', $mResult['Flags'])) if (\strlen($mResult['ReadReceipt']) && !\in_array('$forwarded', $mResult['Flags']))
@ -313,25 +311,19 @@ trait Response
$oAccount = $this->getAccountFromToken(); $oAccount = $this->getAccountFromToken();
$mFoundCIDs = isset($aParameters['FoundCIDs']) && \is_array($aParameters['FoundCIDs']) && $aFoundCIDs = (isset($aParameters['FoundCIDs']) && \is_array($aParameters['FoundCIDs']))
\count($aParameters['FoundCIDs']) ? ? $aParameters['FoundCIDs'] : [];
$aParameters['FoundCIDs'] : null;
$mFoundContentLocationUrls = isset($aParameters['FoundContentLocationUrls']) && $aFoundContentLocationUrls = (isset($aParameters['FoundContentLocationUrls']) && \is_array($aParameters['FoundContentLocationUrls']))
\is_array($aParameters['FoundContentLocationUrls']) && ? $aParameters['FoundContentLocationUrls'] : [];
\count($aParameters['FoundContentLocationUrls']) ?
$aParameters['FoundContentLocationUrls'] : null;
if ($mFoundCIDs || $mFoundContentLocationUrls) if ($aFoundContentLocationUrls) {
{ $aFoundCIDs = \array_merge($aFoundCIDs, $aFoundContentLocationUrls);
$mFoundCIDs = \array_merge($mFoundCIDs ? $mFoundCIDs : array(),
$mFoundContentLocationUrls ? $mFoundContentLocationUrls : array());
$mFoundCIDs = \count($mFoundCIDs) ? $mFoundCIDs : null;
} }
$mResult['IsLinked'] = ($mFoundCIDs && \in_array(\trim(\trim($mResponse->Cid()), '<>'), $mFoundCIDs)) // Hides valid inline attachments in message view 'attachments' section
|| ($mFoundContentLocationUrls && \in_array(\trim($mResponse->ContentLocation()), $mFoundContentLocationUrls)); $mResult['IsLinked'] = \in_array(\trim(\trim($mResponse->Cid()), '<>'), $aFoundCIDs)
|| \in_array(\trim($mResponse->ContentLocation()), $aFoundContentLocationUrls);
$mResult['Framed'] = $this->isFileHasFramedPreview($mResult['FileName']); $mResult['Framed'] = $this->isFileHasFramedPreview($mResult['FileName']);
$mResult['IsThumbnail'] = $this->GetCapa(false, Capa::ATTACHMENT_THUMBNAILS) && $this->isFileHasThumbnail($mResult['FileName']); $mResult['IsThumbnail'] = $this->GetCapa(false, Capa::ATTACHMENT_THUMBNAILS) && $this->isFileHasThumbnail($mResult['FileName']);