From 483d2551eaea6ffc3f7e13c8ea9c3ea215fadff0 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 8 Oct 2014 15:24:19 +0200 Subject: get rid of simplepie absolute url function and use Net url2 --- utility/faviconfetcher.php | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'utility') diff --git a/utility/faviconfetcher.php b/utility/faviconfetcher.php index 8a285a47b..850a7f576 100644 --- a/utility/faviconfetcher.php +++ b/utility/faviconfetcher.php @@ -49,25 +49,8 @@ class FaviconFetcher { if($faviconUrl && $this->isImage($faviconUrl)) { return $faviconUrl; } elseif ($url) { - // try /favicon.ico as fallback - $parts = parse_url($url); - - // malformed url - if ($parts === false || !array_key_exists('host', $parts)) { - return null; - } - - $port = ''; - if (array_key_exists("port", $parts)) { - $port = $parts['port']; - } - - $scheme = 'http'; - if (array_key_exists("scheme", $parts)) { - $scheme = $parts['scheme']; - } - - $faviconUrl = $scheme . "://" . $parts['host'] . $port . "/favicon.ico"; + $base = new \Net_URL2($url); + $faviconUrl = (string) $base->resolve('/favicon.ico'); if($this->isImage($faviconUrl)) { return $faviconUrl; @@ -117,7 +100,8 @@ class FaviconFetcher { if ($elements->length > 0) { /** @noinspection PhpUndefinedMethodInspection */ $iconPath = $this->getAttribute($elements->item(0), 'href'); - $absPath = \SimplePie_Misc::absolutize_url($iconPath, $url); + $base = new \Net_URL2($url); + $absPath = (string) $base->resolve($iconPath, $url); return $absPath; } } @@ -178,9 +162,3 @@ class FaviconFetcher { } } - -/** - * Thrown when no valid url was found by faviconfetcher - */ -class NoValidUrlException extends \Exception { -} -- cgit v1.2.3