diff options
| author | 2017-04-22 23:36:41 +0200 | |
|---|---|---|
| committer | 2017-04-22 23:36:41 +0200 | |
| commit | 57f1e9d6570e86f1bc679ed4897437ae4b14a2b5 (patch) | |
| tree | c0d4cf20c3f40c1d0b6193f832b9e78dc66cee15 | |
| parent | e647f660bbb8f4a8c87843c5fa6e4aab79ab8fe1 (diff) | |
Fix some bugs of Favicon 1.2
https://github.com/ArthurHoaro/favicon/pull/6
https://github.com/ArthurHoaro/favicon/pull/7
| -rw-r--r-- | lib/Favicon/Favicon.php | 18 | ||||
| -rw-r--r-- | lib/favicons.php | 4 |
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/Favicon/Favicon.php b/lib/Favicon/Favicon.php index 7e6c42d6e..39f45f139 100644 --- a/lib/Favicon/Favicon.php +++ b/lib/Favicon/Favicon.php @@ -188,7 +188,10 @@ class Favicon // See if it's specified in a link tag in domain url. if (!$favicon) { - $favicon = $this->getInPage($url); + $favicon = trim($this->getInPage($url)); + } + if (substr($favicon, 0, 2) === '//') { + $favicon = 'https:' . $favicon; } // Make sure the favicon is an absolute URL. @@ -264,9 +267,15 @@ class Favicon foreach ($links as $link) { if ($link->hasAttribute('rel') && strtolower($link->getAttribute('rel')) == 'shortcut icon') { return $link->getAttribute('href'); - } elseif ($link->hasAttribute('rel') && strtolower($link->getAttribute('rel')) == 'icon') { + } + } + foreach ($links as $link) { + if ($link->hasAttribute('rel') && strtolower($link->getAttribute('rel')) == 'icon') { return $link->getAttribute('href'); - } elseif ($link->hasAttribute('href') && strpos($link->getAttribute('href'), 'favicon') !== FALSE) { + } + } + foreach ($links as $link) { + if ($link->hasAttribute('href') && strpos($link->getAttribute('href'), 'favicon') !== FALSE) { return $link->getAttribute('href'); } } @@ -319,7 +328,8 @@ class Favicon $fInfo = finfo_open(FILEINFO_MIME_TYPE); $isImage = strpos(finfo_buffer($fInfo, $content), 'image') !== false; finfo_close($fInfo); - } catch (Exception $e) { + } catch (\Exception $e) { + error_log('Favicon checkImageMTypeContent error: ' . $e->getMessage()); } return $isImage; diff --git a/lib/favicons.php b/lib/favicons.php index 0e80aa145..93e570d27 100644 --- a/lib/favicons.php +++ b/lib/favicons.php @@ -12,10 +12,10 @@ function download_favicon($website, $dest) { syslog(LOG_INFO, 'FreshRSS Favicon discovery GET ' . $website); $favicon_getter = new \Favicon\Favicon(); - $tmpPath = realpath(TMP_PATH) . '/'; + $tmpPath = realpath(TMP_PATH); $favicon_getter->setCacheDir($tmpPath); $favicon_path = $favicon_getter->get($website, \Favicon\FaviconDLType::DL_FILE_PATH); - return ($favicon_path != false && @rename($tmpPath . $favicon_path, $dest)) || + return ($favicon_path != false && @rename($tmpPath . '/' . $favicon_path, $dest)) || @copy($default_favicon, $dest); } |
