Skip to content

[xExtension-YouTube] Silence DOM warnings when showing the feed content - #556

Merged
Alkarex merged 1 commit into
FreshRSS:mainfrom
NopeCharon:youtube-dom-warnings
Oct 23, 2026
Merged

Alkarex merged 1 commit into
FreshRSS:mainfrom
NopeCharon:youtube-dom-warnings

Conversation

@NopeCharon

Copy link
Copy Markdown
Contributor

Summary

  • pass LIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING to the DOMDocument::loadHTML() call used when Display the feeds content is enabled
  • bump the YouTube extension version to 1.3.2 and add a changelog entry

Fixes #222

Root cause

With Display the feeds content enabled, getHtml() parses $entry->content() to extract the enclosure title, thumbnail and description. FreshRSS renders enclosures with HTML5 tags (<figure>, <figcaption>, <video>), which the libxml HTML 4 parser does not know. As a result, every YouTube entry produced warnings such as:

Warning: DOMDocument::loadHTML(): Tag figure invalid in Entity, line: 2
Warning: DOMDocument::loadHTML(): Tag figcaption invalid in Entity, line: 2

These warnings appeared in the middle of the article stream and filled the logs.

The same flags are already used by FreshRSS core (e.g. FreshRSS_Entry, FreshRSS_Feed, lib/favicons.php) and by this extension's own icon downloader. The parser still recovers the same tree, so the generated content is unchanged. This is the stop-gap suggested in the issue until the PHP 8.4+ HTML5 parser can be used (#494).

Validation

  • ran getHtml() against FreshRSS edge with an entry whose enclosure is rendered by FreshRSS_Entry::content(), on PHP 8.2 and PHP 8.5: before the change 4 warnings were emitted (figure, video, figcaption, entity ref), after the change none, and the generated HTML is byte-for-byte identical
  • composer run-script php-lint, composer run-script phtml-lint, phpcs, phpstan (with ../FreshRSS)
  • markdownlint-cli2 on the README

When "Display the feeds content" is enabled, getHtml() parses the entry
content with DOMDocument::loadHTML() to extract the enclosure title,
thumbnail and description. FreshRSS renders enclosures with HTML5 tags
such as <figure>, <figcaption> and <video>, which the libxml HTML 4
parser does not know, so every YouTube entry emitted warnings like:

    Warning: DOMDocument::loadHTML(): Tag figure invalid in Entity

These warnings were printed in the middle of the article stream and
filled the logs.

Pass LIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING to loadHTML(),
the same flags FreshRSS core and this extension's icon downloader
already use when parsing third-party HTML. The parser still recovers
the same tree, so the generated content is unchanged.

Bump the extension version to 1.3.2.

Fixes FreshRSS#222
@Inverle Inverle added the xExtension-YouTube xExtension-YouTube label Oct 23, 2026
@Alkarex
Alkarex merged commit 727013b into FreshRSS:main Oct 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

xExtension-YouTube xExtension-YouTube

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xExtension-YouTube warnings in stream

3 participants