diff --git a/lib/Service/PhishingDetection/LinkCheck.php b/lib/Service/PhishingDetection/LinkCheck.php index cc510f14a5..903215143f 100644 --- a/lib/Service/PhishingDetection/LinkCheck.php +++ b/lib/Service/PhishingDetection/LinkCheck.php @@ -40,6 +40,13 @@ private function getInnerText(\DOMElement $node) : string { return $innerText; } + private function parse(string $url): string { + if(strpos($url, "://") === false && substr($url, 0, 1) != "/") { + $url = "http://".$url; + } + return $url; + } + public function run(string $htmlMessage) : PhishingDetectionResult { $results = []; @@ -62,7 +69,7 @@ public function run(string $htmlMessage) : PhishingDetectionResult { $un = new Normalizer($zipped['href']); $url = $un->normalize(); if($this->textLooksLikeALink($zipped['linkText'])) { - if(parse_url($url, PHP_URL_HOST) !== parse_url($zipped['linkText'], PHP_URL_HOST)) { + if(parse_url($this->parse($url), PHP_URL_HOST) !== parse_url($this->parse($zipped['linkText']), PHP_URL_HOST)) { $results[] = [ 'href' => $url, 'linkText' => $zipped['linkText'],