From c6f098bd2dbc060248a432eb23d664662f99479f Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Wed, 7 Oct 2015 20:06:57 +0300 Subject: [PATCH] Small fixes --- .../libraries/MailSo/Imap/BodyStructure.php | 29 +++++++++++++++++++ .../0.0.0/app/libraries/RainLoop/Actions.php | 4 +-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php index 624f2beb8..65edee844 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php @@ -337,6 +337,26 @@ class BodyStructure return $aReturn; } + /** + * @return \MailSo\Imap\BodyStructure|null + */ + public function SearchInlineEncryptedPart() + { + if ('multipart/encrypted' === \strtolower($this->ContentType())) + { + $aSearchParts = $this->SearchByCallback(function ($oItem) { + return $oItem->IsInline(); + }); + + if (is_array($aSearchParts) && 1 === \count($aSearchParts) && isset($aSearchParts[0])) + { + return $aSearchParts[0]; + } + } + + return null; + } + /** * @return array|null */ @@ -348,6 +368,15 @@ class BodyStructure $mResult = $this->SearchPlainParts(); } + if (null === $mResult || (\is_array($mResult) && 0 === count($mResult))) + { + $oPart = $this->SearchInlineEncryptedPart(); + if ($oPart instanceof \MailSo\Imap\BodyStructure) + { + $mResult = array($oPart); + } + } + return $mResult; } diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 738b0ce35..b8836e9ad 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -9592,8 +9592,8 @@ class Actions }; } - $sHtml = \preg_replace_callback('/]*>([\s\S\r\n\t]*)<\/pre>/mi', function ($aMatches) { - return \preg_replace('/[\r\n]+/', '
', $aMatches[0]); + $sHtml = \preg_replace_callback('/(]*>)([\s\S\r\n\t]*?)(<\/pre>)/mi', function ($aMatches) { + return \preg_replace('/[\r\n]+/', '
', $aMatches[1].\trim($aMatches[2]).$aMatches[3]); }, $sHtml); $mResult['Html'] = 0 === \strlen($sHtml) ? '' : \MailSo\Base\HtmlUtils::ClearHtml(