diff --git a/lib/Service/PhishingDetection/DateCheck.php b/lib/Service/PhishingDetection/DateCheck.php index c68322fe85..aeabee964e 100644 --- a/lib/Service/PhishingDetection/DateCheck.php +++ b/lib/Service/PhishingDetection/DateCheck.php @@ -9,6 +9,7 @@ namespace OCA\Mail\Service\PhishingDetection; +use DateException; use OCA\Mail\PhishingDetectionResult; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IL10N; @@ -24,7 +25,11 @@ public function __construct(IL10N $l10n, ITimeFactory $timeFactory) { public function run(string $date): PhishingDetectionResult { $now = $this->timeFactory->getDateTime('now'); - $dt = $this->timeFactory->getDateTime($date); + try { + $dt = $this->timeFactory->getDateTime($date); + } catch (DateException $e) { + return new PhishingDetectionResult(PhishingDetectionResult::DATE_CHECK, false); + } if ($dt > $now) { return new PhishingDetectionResult(PhishingDetectionResult::DATE_CHECK, true, $this->l10n->t('Sent date is in the future')); } diff --git a/lib/Service/PhishingDetection/LinkCheck.php b/lib/Service/PhishingDetection/LinkCheck.php index 31672f8036..9eb23252ea 100644 --- a/lib/Service/PhishingDetection/LinkCheck.php +++ b/lib/Service/PhishingDetection/LinkCheck.php @@ -63,6 +63,14 @@ public function run(string $htmlMessage) : PhishingDetectionResult { if ($href === '') { continue; } + // handle links that are wrapped in brackets, quotes, etc. + $firstChar = $linkText[0]; + $lastChar = $linkText[strlen($linkText) - 1]; + + if (!ctype_alpha($firstChar) && !ctype_alpha($lastChar)) { + $linkText = substr($linkText, 1, -1); + } + $zippedArray[] = [ 'href' => $href, 'linkText' => $linkText