Skip to content

fix: fall back to plain text when RSS item content triggers RecursionError - #2333

Open
Jeremy Schoemaker (shoemoney) wants to merge 1 commit into
microsoft:mainfrom
shoemoney:fix/rss-recursion-fallback
Open

fix: fall back to plain text when RSS item content triggers RecursionError#2333
Jeremy Schoemaker (shoemoney) wants to merge 1 commit into
microsoft:mainfrom
shoemoney:fix/rss-recursion-fallback

Conversation

@shoemoney

Copy link
Copy Markdown

RssConverter._parse_content wraps markdownify conversion in a broad except BaseException that returns the original content. When an RSS item's description or content:encoded contains deeply nested HTML (roughly 400+ levels), markdownify's recursive DOM traversal raises RecursionError, and the converter silently embeds the raw unconverted HTML in the markdown output.

This PR mirrors the fix merged in #1644 for the HTML converter: catch RecursionError specifically, emit a warning, and fall back to BeautifulSoup's iterative get_text() so callers still get usable plain-text content. Other exceptions keep the existing behavior.

Includes a deterministic regression test using the same sys.setrecursionlimit pattern as the #1644 test: a feed item with 500 nested divs must produce text output with no raw HTML tags. Before the fix the output contained 500 raw <div tags; after, none. black --check clean.

…Error

Deeply nested HTML inside an RSS item's description or content:encoded
previously hit the broad except in _parse_content and returned the raw
unconverted HTML, silently embedding HTML tags in the markdown output.

Catch RecursionError specifically and fall back to BeautifulSoup's
iterative get_text(), mirroring the HTML converter fix from microsoft#1644.
Includes a deterministic regression test.
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.

1 participant