mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-05 15:37:03 +03:00
Added IMAP body text limit
This commit is contained in:
parent
037f4dc61c
commit
0fc8967a7f
5 changed files with 59 additions and 10 deletions
|
|
@ -407,6 +407,7 @@ class HtmlUtils
|
|||
$aContentLocationUrls = array(), &$aFoundedContentLocationUrls = array(),
|
||||
$bDoNotReplaceExternalUrl = false, $bFindLinksInHtml = false, $fAdditionalExternalFilter = null)
|
||||
{
|
||||
$sResult = '';
|
||||
$sHtml = null === $sHtml ? '' : (string) $sHtml;
|
||||
$sHtml = \trim($sHtml);
|
||||
if (0 === \strlen($sHtml))
|
||||
|
|
@ -591,10 +592,10 @@ class HtmlUtils
|
|||
$oElement->setAttribute('data-x-src', $sSrc);
|
||||
if ($fAdditionalExternalFilter)
|
||||
{
|
||||
$sResult = \call_user_func($fAdditionalExternalFilter, $sSrc);
|
||||
if (0 < \strlen($sResult))
|
||||
$sCallResult = \call_user_func($fAdditionalExternalFilter, $sSrc);
|
||||
if (0 < \strlen($sCallResult))
|
||||
{
|
||||
$oElement->setAttribute('data-x-additional-src', $sResult);
|
||||
$oElement->setAttribute('data-x-additional-src', $sCallResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,7 +337,8 @@ class MailClient
|
|||
* @param string $sFolderName
|
||||
* @param int $iIndex
|
||||
* @param bool $bIndexIsUid = true
|
||||
* @param mixed $oCacher = null
|
||||
* @param \MailSo\Cache\CacheClient $oCacher = null
|
||||
* @param int $iBodyTextLimit = null
|
||||
*
|
||||
* @return \MailSo\Mail\Message|false
|
||||
*
|
||||
|
|
@ -345,7 +346,7 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Imap\Exceptions\Exception
|
||||
*/
|
||||
public function Message($sFolderName, $iIndex, $bIndexIsUid = true, $oCacher = null)
|
||||
public function Message($sFolderName, $iIndex, $bIndexIsUid = true, $oCacher = null, $iBodyTextLimit = null)
|
||||
{
|
||||
if (!\MailSo\Base\Validator::RangeInt($iIndex, 1))
|
||||
{
|
||||
|
|
@ -356,7 +357,9 @@ class MailClient
|
|||
|
||||
$oBodyStructure = null;
|
||||
$oMessage = false;
|
||||
|
||||
$aBodyPeekMimeIndexes = array();
|
||||
$aSignatureMimeIndexes = array();
|
||||
|
||||
$aFetchResponse = $this->oImapClient->Fetch(array(\MailSo\Imap\Enumerations\FetchType::BODYSTRUCTURE), $iIndex, $bIndexIsUid);
|
||||
if (0 < \count($aFetchResponse) && isset($aFetchResponse[0]))
|
||||
|
|
@ -369,7 +372,7 @@ class MailClient
|
|||
{
|
||||
foreach ($aTextParts as $oPart)
|
||||
{
|
||||
$aBodyPeekMimeIndexes[] = $oPart->PartID();
|
||||
$aBodyPeekMimeIndexes[] = array($oPart->PartID(), $oPart->Size());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -378,7 +381,7 @@ class MailClient
|
|||
{
|
||||
foreach ($aSignatureParts as $oPart)
|
||||
{
|
||||
$aBodyPeekMimeIndexes[] = $oPart->PartID();
|
||||
$aSignatureMimeIndexes[] = $oPart->PartID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -395,7 +398,21 @@ class MailClient
|
|||
|
||||
if (0 < \count($aBodyPeekMimeIndexes))
|
||||
{
|
||||
foreach ($aBodyPeekMimeIndexes as $sTextMimeIndex)
|
||||
foreach ($aBodyPeekMimeIndexes as $aTextMimeData)
|
||||
{
|
||||
$sLine = \MailSo\Imap\Enumerations\FetchType::BODY_PEEK.'['.$aTextMimeData[0].']';
|
||||
if (\is_numeric($iBodyTextLimit) && 0 < $iBodyTextLimit && $iBodyTextLimit < $aTextMimeData[1])
|
||||
{
|
||||
$sLine .= '<0.'.((int) $iBodyTextLimit).'>';
|
||||
}
|
||||
|
||||
$aFetchItems[] = $sLine;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < \count($aSignatureMimeIndexes))
|
||||
{
|
||||
foreach ($aSignatureMimeIndexes as $sTextMimeIndex)
|
||||
{
|
||||
$aFetchItems[] = \MailSo\Imap\Enumerations\FetchType::BODY_PEEK.'['.$sTextMimeIndex.']';
|
||||
}
|
||||
|
|
@ -1467,7 +1484,7 @@ class MailClient
|
|||
/**
|
||||
* @param string $sFolderName
|
||||
* @param string $sFolderHash
|
||||
* @param mixed $oCacher
|
||||
* @param \MailSo\Cache\CacheClient $oCacher
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
|
|
|
|||
|
|
@ -163,6 +163,11 @@ class Message
|
|||
*/
|
||||
private $iThreadsLen;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bTextPartIsTrimmed;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -229,6 +234,8 @@ class Message
|
|||
$this->iThreadsLen = 0;
|
||||
$this->iParentThread = 0;
|
||||
|
||||
$this->bTextPartIsTrimmed = false;
|
||||
|
||||
$this->sPgpSignature = '';
|
||||
$this->bPgpSigned = false;
|
||||
$this->bPgpEncrypted = false;
|
||||
|
|
@ -558,6 +565,14 @@ class Message
|
|||
$this->iParentThread = $iParentThread;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boole
|
||||
*/
|
||||
public function TextPartIsTrimmed()
|
||||
{
|
||||
return $this->bTextPartIsTrimmed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFolder
|
||||
* @param \MailSo\Imap\FetchResponse $oFetchResponse
|
||||
|
|
@ -774,6 +789,15 @@ class Message
|
|||
foreach ($aTextParts as $oPart)
|
||||
{
|
||||
$sText = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::BODY.'['.$oPart->PartID().']');
|
||||
if (null === $sText)
|
||||
{
|
||||
$sText = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::BODY.'['.$oPart->PartID().']<0>');
|
||||
if (\is_string($sText) && 0 < \strlen($sText))
|
||||
{
|
||||
$this->bTextPartIsTrimmed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (\is_string($sText) && 0 < \strlen($sText))
|
||||
{
|
||||
$sTextCharset = $oPart->Charset();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue