From f0bb3a8a45ca2fd7548768deff27bc6788994343 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Mon, 22 Jan 2024 13:33:00 +0100 Subject: [PATCH] Handle message hasVirus header in JavaScript --- dev/Model/Message.js | 19 ++++++++++++-- .../app/libraries/MailSo/Mail/Message.php | 25 ------------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/dev/Model/Message.js b/dev/Model/Message.js index 000635e34..fd407b3f2 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -257,13 +257,28 @@ export class MessageModel extends AbstractModel { } // Unsubscribe links - value = headers.valueByName('List-Unsubscribe'); - if (value) { + if (value = headers.valueByName('List-Unsubscribe')) { this.unsubsribeLinks(value.split(',').map( link => link.replace(/^[ <>]+|[ <>]+$/g, '') )); } + if (headers.valueByName('X-Virus')) { + this.hasVirus(true); + } + if (value = headers.valueByName('X-Virus-Status')) { + if (value.includes('infected')) { + this.hasVirus(true); + } else if (value.includes('clean')) { + this.hasVirus(false); + } + } +/* + if (value = headers.valueByName('X-Virus-Scanned')) { + this.virusScanned(value); + } +*/ + return true; } } diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php index 6e470f098..4f5954657 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php @@ -27,7 +27,6 @@ class Message implements \JsonSerializable $sMessageId = '', $sContentType = '', $sSpamResult = '', - $sVirusScanned = '', $InReplyTo = '', $sPlain = '', $sHtml = '', @@ -57,14 +56,6 @@ class Message implements \JsonSerializable private bool $bIsSpam = false; - private ?bool - /** - * null = not scanned - * true = scanned and infected - * false = scanned and no infection found - */ - $bHasVirus = null; - private array $SPF = [], $DKIM = [], @@ -246,20 +237,6 @@ class Message implements \JsonSerializable || false !== \stripos($oHeaders->ValueByName(MimeHeader::X_SPAM_FLAG), 'YES'); } - if ($virus = $oHeaders->ValueByName(MimeHeader::X_VIRUS)) { - $oMessage->bHasVirus = true; - } - if ($virus = $oHeaders->ValueByName(MimeHeader::X_VIRUS_STATUS)) { - if (false !== \stripos($spam, 'infected')) { - $oMessage->bHasVirus = true; - } else if (false !== \stripos($spam, 'clean')) { - $oMessage->bHasVirus = false; - } - } - if ($virus = $oHeaders->ValueByName(MimeHeader::X_VIRUS_SCANNED)) { - $oMessage->sVirusScanned = $virus; - } - $sDraftInfo = $oHeaders->ValueByName(MimeHeader::X_DRAFT_INFO); if (\strlen($sDraftInfo)) { $sType = ''; @@ -510,8 +487,6 @@ class Message implements \JsonSerializable 'spamScore' => $this->bIsSpam ? 100 : $this->SpamScore, 'spamResult' => $this->sSpamResult, 'isSpam' => $this->bIsSpam, - 'hasVirus' => $this->bHasVirus, -// 'virusScanned' => $this->sVirusScanned, 'dateTimestamp' => $this->iHeaderTimeStampInUTC ?: $this->iInternalTimeStampInUTC, 'internalTimestamp' => $this->iInternalTimeStampInUTC,