Skip to content

Commit

Permalink
Resolve relative URLs during feed discovery
Browse files Browse the repository at this point in the history
When a feed is added using the feed discovery feature, and the feed link
uses a relative URL, the discovery needs to resolve the URL relative
to the provided website URL.

Fixes nextcloud#1385

Signed-off-by: Mormegil <[email protected]>
  • Loading branch information
mormegil-cz committed Jan 12, 2022
1 parent b050f75 commit 6eba9d0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Service/FeedServiceV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use FeedIo\Explorer;
use FeedIo\Reader\ReadErrorException;
use HTMLPurifier;
use Net_URL2;

use OCA\News\Db\FeedMapperV2;
use OCA\News\Fetcher\FeedFetcher;
Expand Down Expand Up @@ -199,7 +200,13 @@ public function create(
if ($full_discover) {
$feeds = $this->explorer->discover($feedUrl);
if ($feeds !== []) {
$feedUrl = array_shift($feeds);
$discoveredUrl = array_shift($feeds);
$url2 = new Net_URL2($discoveredUrl);
if ($url2->isAbsolute()) {
$feedUrl = $discoveredUrl;
} else {
$feedUrl = strval((new Net_URL2($feedUrl))->resolve($discoveredUrl));
}
}
}

Expand Down

0 comments on commit 6eba9d0

Please sign in to comment.