Skip to content

fix: keep the item links of an RSS feed whose HTML contains <link> tags - #1002

Merged
adbar merged 2 commits into
adbar:masterfrom
RavSinghChandan:rss-links-before-atom
Oct 26, 2026
Merged

adbar merged 2 commits into
adbar:masterfrom
RavSinghChandan:rss-links-before-atom

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

find_links() treats a feed as Atom as soon as it contains any <link ... href=...> tag. An RSS feed can contain one in the HTML of an item, for example <link rel="stylesheet" href="..."> inside a <description> CDATA block. Such a feed was then read as Atom: extract_links() returned only that stylesheet URL, and all the <link> elements of the items were lost.

A feed whose root element is <rss> or <rdf:RDF> (after the XML declaration, comments and doctype) and that has <link> elements is now read as RSS first. Atom feeds, JSON feeds, and RSS feeds without <link> elements behave as before. Added a test with an RSS 2.0 and an RSS 1.0 feed whose item HTML contains a <link> tag.

Comment thread trafilatura/feeds.py Fixed
Comment thread trafilatura/feeds.py Fixed
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.95%. Comparing base (6096de4) to head (5f6750f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1002   +/-   ##
=======================================
  Coverage   99.95%   99.95%           
=======================================
  Files          21       21           
  Lines        4291     4306   +15     
=======================================
+ Hits         4289     4304   +15     
  Misses          2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RavSinghChandan

Copy link
Copy Markdown
Contributor Author

CodeQL flagged the regex I used to find the RSS root (nested repetitions could backtrack on a crafted feed). It is now a small linear scan over the XML declaration, comments and doctype, with tests for the adversarial inputs CodeQL described. All checks pass now.

@adbar
adbar merged commit f1619df into adbar:master Oct 26, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants