summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-04-23 18:10:13 +0200
committerGravatar GitHub <noreply@github.com> 2017-04-23 18:10:13 +0200
commit251f11c1d7613321b2137467831ce68ae921231d (patch)
tree92fbc3445c86f5083f118cf3c60b3606e92cd433 /lib
parentb95a2c192e1879f7353659728c6bd25304230086 (diff)
parent2ffb00c37fd0299ad7f13137115091fd62582ac6 (diff)
Merge pull request #1505 from Alkarex/protocol-relative-favicon
Better handling of protocol-relative favicons
Diffstat (limited to 'lib')
-rw-r--r--lib/favicons.php7
1 files changed, 6 insertions, 1 deletions
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);