From 241f69e4db786daac259f1c7641006e1d2e28e2b Mon Sep 17 00:00:00 2001 From: wn_ Date: Sun, 1 Oct 2017 14:25:12 -0500 Subject: Handle potentially-relative base element when getting favicon. The base element's "href" attribute is not required to be absolute, so rewrite relative to the site URL if it is relative. See: * https://www.w3.org/TR/html51/document-metadata.html#the-base-element * https://html.spec.whatwg.org/multipage/semantics.html#the-base-element --- include/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/functions.php b/include/functions.php index 8ea8719ca..71a6be2e9 100644 --- a/include/functions.php +++ b/include/functions.php @@ -577,7 +577,7 @@ $base = $xpath->query('/html/head/base'); foreach ($base as $b) { - $url = $b->getAttribute("href"); + $url = rewrite_relative_url($url, $b->getAttribute("href")); break; } -- cgit v1.2.3 From 701c5a7ee47f1236ffb55a9ebb707c46da2c7b91 Mon Sep 17 00:00:00 2001 From: wn_ Date: Sun, 1 Oct 2017 15:47:31 -0500 Subject: get_favicon_url: only check base elements with href attribute --- include/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/functions.php b/include/functions.php index 71a6be2e9..203454747 100644 --- a/include/functions.php +++ b/include/functions.php @@ -575,7 +575,7 @@ $doc->loadHTML($html); $xpath = new DOMXPath($doc); - $base = $xpath->query('/html/head/base'); + $base = $xpath->query('/html/head/base[@href]'); foreach ($base as $b) { $url = rewrite_relative_url($url, $b->getAttribute("href")); break; -- cgit v1.2.3