diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-21 13:53:22 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-21 13:53:22 +0200 |
commit | 1140199677f93a3958a0a19271d0f853d9330c30 (patch) | |
tree | f872dd8246e31b0c8e10d1e3609bf7c22a182151 | |
parent | 6b64036662a8d2cad397f524532f68a51d41d773 (diff) |
if feed has no title, use its url, fix #108
-rw-r--r-- | tests/unit/utility/FeedFetcherTest.php | 22 | ||||
-rw-r--r-- | utility/feedfetcher.php | 9 |
2 files changed, 30 insertions, 1 deletions
diff --git a/tests/unit/utility/FeedFetcherTest.php b/tests/unit/utility/FeedFetcherTest.php index 30881ae0d..3d1f2a340 100644 --- a/tests/unit/utility/FeedFetcherTest.php +++ b/tests/unit/utility/FeedFetcherTest.php @@ -244,6 +244,28 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility { } + public function testFetchMapItemsNoFeedTitleUsesUrl(){ + $this->expectCore('get_title', ''); + $this->expectCore('get_link', $this->feedLink); + + $feed = new Feed(); + $feed->setTitle($this->url); + $feed->setUrl($this->url); + $feed->setLink($this->feedLink); + $feed->setUrlHash(md5($this->url)); + $feed->setAdded($this->time); + $feed->setFaviconLink(null); + + $this->core->expects($this->once()) + ->method('init') + ->will($this->returnValue(true)); + $item = $this->createItem(); + $this->expectCore('get_items', array($this->item)); + $result = $this->fetcher->fetch($this->url); + + $this->assertEquals(array($feed, array($item)), $result); + } + public function testFetchMapItemsAuthorExists(){ $this->core->expects($this->once()) ->method('init') diff --git a/utility/feedfetcher.php b/utility/feedfetcher.php index f72a14439..c54dabf05 100644 --- a/utility/feedfetcher.php +++ b/utility/feedfetcher.php @@ -141,7 +141,14 @@ class FeedFetcher implements IFeedFetcher { $feed = new Feed(); // unescape content because angularjs helps agains XSS - $feed->setTitle(html_entity_decode($simplePieFeed->get_title())); + $title = html_entity_decode($simplePieFeed->get_title()); + + // if there is no title use the url + if(!$title) { + $title = $url; + } + + $feed->setTitle($title); $feed->setUrl($url); $feed->setLink($simplePieFeed->get_link()); $feed->setUrlHash(md5($url)); |