Skip to content

Commit

Permalink
Merge pull request #10073 from nextcloud/fix/link-checking
Browse files Browse the repository at this point in the history
fix: link checking missing scheme
  • Loading branch information
kesselb authored Sep 2, 2024
2 parents f5f1085 + 9bb48cd commit 2490ae8
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(!str_contains($url, '://')) {
return '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 2490ae8

Please sign in to comment.