Skip to content

Commit

Permalink
fix: link checking missing scheme
Browse files Browse the repository at this point in the history
Signed-off-by: Hamza Mahjoubi <[email protected]>
  • Loading branch information
hamza221 committed Aug 30, 2024
1 parent 62f1cec commit f5b2dc7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Service/PhishingDetection/LinkCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ private function getInnerText(\DOMElement $node) : string {
return $innerText;
}

private function parse(string $url): string {
if(strpos($url, "://") === false) {
$url = "http://".$url;
}
return $url;
}

public function run(string $htmlMessage) : PhishingDetectionResult {

$results = [];
Expand All @@ -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'],
Expand Down

0 comments on commit f5b2dc7

Please sign in to comment.