Repository navigation
fix: resolve ../ and ./ relative links in feed item HTML content - #95
Merged
Merged
Conversation
|
Resolves: nextcloud/news#3822 |
There was a problem hiding this comment.
Pull request overview
Fixes feed item HTML rewriting so ../ and ./ relative href/src links embedded in item content/description are resolved into absolute URLs based on the item’s full link, improving correctness for feeds that embed relative paths in CDATA.
Changes:
- Add relative-path (
..//./) URL resolution step toNode::setHostInContent()via a new private helper. - Add PHPUnit coverage for
../,./, and “already absolute” cases. - Add an RSS fixture containing relative links and document the fix in the changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/FeedIo/Feed/Node.php | Adds logic to resolve ../ / ./ links in content/description to absolute URLs. |
| tests/FeedIo/Feed/NodeTest.php | Adds tests validating relative-path resolution and no-op behavior for absolute URLs. |
| tests/samples/rss/sample-rss-relative-links.xml | Adds an RSS sample fixture with relative href/src values in CDATA. |
| CHANGELOG.md | Records the fix under Unreleased. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add resolveRelativePathLinksInContent() private method to Node that handles href/src attributes starting with ../ or ./. These paths are normalized against the item's base directory using stack-based path resolution, then replaced with absolute URLs. Previously, Node::setHostInContent() only handled: - /absolute/path hrefs - #fragment hrefs - word-starting relative hrefs (e.g. page.html) Relative paths with dot segments (../path, ./path) were left unresolved, breaking links in feeds like https://wiki.xxiivv.com/links/log.xml whose <description> elements contain HTML with ../media/ and ../site/ hrefs. Also add tests and a sample RSS fixture with relative ../ links.
Grotax
force-pushed
the
copilot/check-relative-link-resolution
branch
from
July 19, 2026 09:28
2b6c706 to
0131fcb
Compare
Grotax
approved these changes
Jul 19, 2026
Grotax
marked this pull request as ready for review
July 19, 2026 09:28
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Node::setHostInContent()left../and./relative paths unresolved in item HTML content. Feeds likehttps://wiki.xxiivv.com/links/log.xmlembed relative links (href='../site/page.html',src='../media/image.png') in<description>CDATA, which were passed through unchanged.Changes
src/FeedIo/Feed/Node.php— adds privateresolveRelativePathLinksInContent(string $itemFullLink), called fromsetHostInContent()between the#fragmentand bare-word handlers. Usespreg_replace_callbackwith a backreference-aware pattern to match both'- and"-quoted..//./attributes, then normalizes each path via a stack-based resolver (RFC 3986–style) against the item's base directory:tests/FeedIo/Feed/NodeTest.php— adds three tests:../resolution,./resolution, and no-op on already-absolute URLs.tests/samples/rss/sample-rss-relative-links.xml— minimal RSS fixture modelled on the xxiivv feed structure.