-
-
Notifications
You must be signed in to change notification settings - Fork 1
Fix: Analysis of relative links (Node.php) #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the analysis of relative links in Atom feeds by improving URL resolution logic. The changes ensure that relative URLs in feed items are properly converted to absolute URLs using the base feed URL.
- Adds comprehensive relative URL resolution logic for Atom links
- Introduces a separate
linkForAnalysisproperty to track the original feed URL for relative URL resolution - Updates content processing to handle various types of relative URLs (fragment, query, path-based)
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/FeedIo/Rule/Atom/Link.php | Implements relative URL resolution by checking if href has a host and prepending base URL |
| src/FeedIo/Feed/Node.php | Adds linkForAnalysis property and enhanced setHostInContent method for URL processing |
| src/FeedIo/Parser/XmlParser.php | Updates to use setLinkForAnalysis instead of setLink for item parsing |
| tests/FeedIo/Rule/Atom/LinkTest.php | Adds comprehensive test coverage for various relative URL scenarios |
| CHANGELOG.md | Documents the fix for relative links analysis |
Comments suppressed due to low confidence (1)
src/FeedIo/Feed/Node.php:187
- The regex pattern has unbalanced parentheses - there are 6 opening parentheses but only 5 closing parentheses. This will cause a preg_replace error. The pattern should be properly balanced.
$pattern = '(<\s*[^>]*)(href=|src=)(.?)(\w+\b)(?![:])(?!(.(?!<code))*<\/code>)';
1 Cannot use the "Link" object to analyze relative links Because the "Link" for the Atom feed will be corrupted. Use the additionally created "LinkForAnalysis" object 2. - Fix: Error preg_replace(), add all other possible replacements for relative links. - Replaced links like href="#aaa/bbb.xxx" - Replaced links like href="aaa/bbb.xxx" Similar to alexdebril#427 Use the new method "setLinkForAnalysis" instead of "setLink" (XmlParser.php) Added analysis of relative links for the Atom feed (Link.php)
Co-authored-by: Sean Molenaar <[email protected]>
|
@SMillerDev tests are still failing after your changes |
|
I removed the problematic commits, maybe code quality can be improved another time |
Import of alexdebril#433
Also cherry-picked the adjustments from the PR for 5.3.x