From f416213993bc014664fde940df050aa6225e08a7 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Tue, 12 Mar 2019 14:00:05 +0100 Subject: Fix email and password not being encoded --- lib/Fetcher/FeedFetcher.php | 7 +++++-- tests/Unit/Fetcher/FeedFetcherTest.php | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/Fetcher/FeedFetcher.php b/lib/Fetcher/FeedFetcher.php index 898597460..9b4a2f996 100755 --- a/lib/Fetcher/FeedFetcher.php +++ b/lib/Fetcher/FeedFetcher.php @@ -67,7 +67,7 @@ class FeedFetcher implements IFeedFetcher { if (!empty($user) && !empty(trim($user))) { $url = explode('://', $url); - $url = $url[0] . '://' . $user . ':' . $password . '@' . $url[1]; + $url = $url[0] . '://' . urlencode($user) . ':' . urlencode($password) . '@' . $url[1]; } if (is_null($lastModified) || !is_string($lastModified)) { $resource = $this->reader->read($url); @@ -95,7 +95,10 @@ class FeedFetcher implements IFeedFetcher ); $items = []; - $this->logger->debug('Feed ' . $url . ' was modified since last fetch. #' . count($parsedFeed) . ' items'); + $this->logger->debug('Feed {url} was modified since last fetch. #{count} items', [ + 'url' => $url, + 'count' => count($parsedFeed), + ]); foreach ($parsedFeed as $item) { $items[] = $this->buildItem($item, $parsedFeed); } diff --git a/tests/Unit/Fetcher/FeedFetcherTest.php b/tests/Unit/Fetcher/FeedFetcherTest.php index c7f42a63e..8f031d365 100644 --- a/tests/Unit/Fetcher/FeedFetcherTest.php +++ b/tests/Unit/Fetcher/FeedFetcherTest.php @@ -229,6 +229,17 @@ class FeedFetcherTest extends TestCase $this->assertEquals([$feed, [$item]], $result); } + public function testFetchAccount() + { + $this->__setUpReader('http://account%40email.com:F9sEU%2ARt%25%3AKFK8HMHT%26@tests'); + $item = $this->_createItem(); + $feed = $this->_createFeed('de-DE', false, 'http://account%40email.com:F9sEU%2ARt%25%3AKFK8HMHT%26@tests'); + $this->_mockIterator($this->feed_mock, [$this->item_mock]); + $result = $this->fetcher->fetch($this->url, false, null, 'account@email.com', 'F9sEU*Rt%:KFK8HMHT&'); + + $this->assertEquals([$feed, [$item]], $result); + } + public function testAudioEnclosure() { @@ -496,8 +507,9 @@ class FeedFetcherTest extends TestCase } - private function _createFeed($lang='de-DE', $favicon=false) + private function _createFeed($lang='de-DE', $favicon=false, $url= null) { + $url = $url ?? $this->url; $this->_expectFeed('getTitle', $this->feed_title, 2); $this->_expectFeed('getLink', $this->feed_link); $this->_expectFeed('getLastModified', $this->modified); @@ -508,7 +520,7 @@ class FeedFetcherTest extends TestCase $feed->setTitle('&its a title'); $feed->setLink($this->feed_link); $feed->setLocation($this->location); - $feed->setUrl($this->url); + $feed->setUrl($url); $feed->setLastModified(3); $feed->setAdded($this->time); if ($favicon) { -- cgit v1.2.3