From 2ffb00c37fd0299ad7f13137115091fd62582ac6 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 23 Apr 2017 18:00:48 +0200 Subject: Better handling of protocol-relative favicons https://github.com/ArthurHoaro/favicon/pull/6/commits/cd5f98ecdd1d38e8bc5d87fd09c80079a74191ba https://github.com/FreshRSS/FreshRSS/pull/1504 --- lib/favicons.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/favicons.php') diff --git a/lib/favicons.php b/lib/favicons.php index de993ec8a..62a21a246 100644 --- a/lib/favicons.php +++ b/lib/favicons.php @@ -61,7 +61,12 @@ function searchFavicon(&$url) { strtolower(trim($link->getAttribute('rel'))) === $rel) { $href = trim($link->getAttribute('href')); if (substr($href, 0, 2) === '//') { - $href = 'https:' . $href; + // Case of protocol-relative URLs + if (preg_match('%^(https?:)//%i', $url, $matches)) { + $href = $matches[1] . $href; + } else { + $href = 'https:' . $href; + } } if (filter_var($href, FILTER_VALIDATE_URL) === false) { $href = SimplePie_IRI::absolutize($url, $href); -- cgit v1.2.3