diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-14 00:30:01 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-14 00:30:01 +0200 |
commit | b4818a403ac7890dd5436d505f9a4e6135cbe8e4 (patch) | |
tree | 24294ec96e6b2c7ecf5fe0738db300c2464e9f28 | |
parent | 36dc56717ab1a32a73377dad9875ce82ddf59f32 (diff) |
also check https for favicons
-rw-r--r-- | js/tests/services/bl/feedblSpec.coffee | 4 | ||||
-rw-r--r-- | utility/feedfetcher.php | 21 |
2 files changed, 14 insertions, 11 deletions
diff --git a/js/tests/services/bl/feedblSpec.coffee b/js/tests/services/bl/feedblSpec.coffee index 6e83874b2..0c538e2e3 100644 --- a/js/tests/services/bl/feedblSpec.coffee +++ b/js/tests/services/bl/feedblSpec.coffee @@ -189,7 +189,7 @@ describe 'FeedBl', -> expect(@FeedBl.getAll()).toContain(item2) - it 'should retunr if ShowAll is set', => + it 'should return if ShowAll is set', => @persistence.userSettingsReadShow = jasmine.createSpy('Show All') expect(@FeedBl.isShowAll()).toBe(false) @FeedBl.setShowAll(true) @@ -260,7 +260,7 @@ describe 'FeedBl', -> expect(feed.urlHash).toBe(hash) expect(feed.folderId).toBe(0) expect(feed.unreadCount).toBe(0) - + expect(@imagePath).toHaveBeenCalledWith('core', 'loading.gif') it 'should transform urls correctly', => urls = [ diff --git a/utility/feedfetcher.php b/utility/feedfetcher.php index d07b5f0f9..4b91865f5 100644 --- a/utility/feedfetcher.php +++ b/utility/feedfetcher.php @@ -158,15 +158,8 @@ class FeedFetcher implements IFeedFetcher { private function discoverFavicon($url) { - // try the /favicon.ico $url = rtrim($url, '/'); - $baseFavicon = $url . '/favicon.ico'; - if($this->isValidFavIcon($baseFavicon)){ - return $baseFavicon; - } - - //try to extract favicon from web page $page = $this->api->getUrlContent($url); @@ -186,12 +179,14 @@ class FeedFetcher implements IFeedFetcher { // if it does not start with http, add it if (strpos($favicon, 'http') !== 0){ $favicon = 'http://' . $favicon; - } + $httpsFavicon = 'https://' . $favicon; + } // if its already valid, return it if ($this->isValidFavIcon($favicon)){ return $favicon; - + } elseif ($this->isValidFavIcon($httpsFavicon)){ + return $httpsFavicon; // assume its a realtive path or absolute path } else { // add slash to make it absolute @@ -206,6 +201,14 @@ class FeedFetcher implements IFeedFetcher { } } } + + // try the /favicon.ico as a last resort + $parseUrl = parse_url($url); + $baseFavicon = $parseUrl['scheme'] . '://' . $parseUrl['host'] . '/favicon.ico'; + if($this->isValidFavIcon($baseFavicon)){ + return $baseFavicon; + } + return null; } }
\ No newline at end of file |