diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-15 18:49:44 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-15 18:49:44 +0200 |
commit | 34342814a0e66764e36f815d23479f1735f146fc (patch) | |
tree | 99b9d1c4a8fc41de1477543b52f25c8432febb01 | |
parent | 0ed9131f3f1c851158421b39767bf94264f80b8b (diff) |
fix potential errors when fetching favicon that preven feed from being added, fix #66 by not shortening the url
-rw-r--r-- | js/app/services/businesslayer/feedbusinesslayer.coffee | 4 | ||||
-rw-r--r-- | js/public/app.js | 2 | ||||
-rw-r--r-- | js/tests/services/businesslayer/feedbusinesslayerSpec.coffee | 17 | ||||
-rw-r--r-- | utility/feedfetcher.php | 13 |
4 files changed, 15 insertions, 21 deletions
diff --git a/js/app/services/businesslayer/feedbusinesslayer.coffee b/js/app/services/businesslayer/feedbusinesslayer.coffee index d83e38268..fcdcc8093 100644 --- a/js/app/services/businesslayer/feedbusinesslayer.coffee +++ b/js/app/services/businesslayer/feedbusinesslayer.coffee @@ -140,9 +140,7 @@ FeedModel, NewLoading, _ExistsError, Utils) -> throw new _ExistsError('Exists already') feed = - title: url.replace( - /^(?:https?:\/\/)?(?:www\.)?([a-z0-9_\-\.]+)(?:\/.*)?$/gi, - '$1') + title: url url: url urlHash: urlHash folderId: parentId diff --git a/js/public/app.js b/js/public/app.js index 02fc9c32c..c76a338ee 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -896,7 +896,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. throw new _ExistsError('Exists already'); } feed = { - title: url.replace(/^(?:https?:\/\/)?(?:www\.)?([a-z0-9_\-\.]+)(?:\/.*)?$/gi, '$1'), + title: url, url: url, urlHash: urlHash, folderId: parentId, diff --git a/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee b/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee index 1ee9aaa3d..476d74d30 100644 --- a/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee +++ b/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee @@ -255,28 +255,13 @@ describe 'FeedBusinessLayer', -> feed = @FeedModel.getByUrlHash(hash) - expect(feed.title).toBe('google.de') + expect(feed.title).toBe('www.google.de') expect(feed.url).toBe(url) 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 = [ - 'www.google.de' - 'www.google.de/' - 'google.de' - 'http://google.de' - 'http://www.google.de/' - ] - for url in urls - @FeedModel.clear() - @FeedBusinessLayer.create(url) - hash = hex_md5(url) - feed = @FeedModel.getByUrlHash(hash) - expect(feed.title).toBe('google.de') - it 'should make a create feed request', => @persistence.createFeed = jasmine.createSpy('add feed') diff --git a/utility/feedfetcher.php b/utility/feedfetcher.php index 4b91865f5..1f67d328e 100644 --- a/utility/feedfetcher.php +++ b/utility/feedfetcher.php @@ -204,7 +204,18 @@ class FeedFetcher implements IFeedFetcher { // try the /favicon.ico as a last resort $parseUrl = parse_url($url); - $baseFavicon = $parseUrl['scheme'] . '://' . $parseUrl['host'] . '/favicon.ico'; + if (!array_key_exists('scheme', $parseUrl)){ + $scheme = 'http'; + } else { + $scheme = $parseUrl['scheme']; + } + + if(!array_key_exists('host', $parseUrl)){ + error_log($url); + return null; + } + + $baseFavicon = $scheme . '://' . $parseUrl['host'] . '/favicon.ico'; if($this->isValidFavIcon($baseFavicon)){ return $baseFavicon; } |