Skip to content

fix: resolve RSS feed validation errors#451

Open
Zerthick wants to merge 4 commits into
Guts:mainfrom
Zerthick:fix/rss-validation-errors
Open

fix: resolve RSS feed validation errors#451
Zerthick wants to merge 4 commits into
Guts:mainfrom
Zerthick:fix/rss-validation-errors

Conversation

@Zerthick

@Zerthick Zerthick commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Fixes three RSS 2.0 validation errors in the generated feed.

Changes

1. <author><dc:creator> for item authors (template)

The RSS 2.0 spec requires <author> to be an email address (e.g., user@example.com). The plugin was using it for display names, which causes validation failures on every feed validator. Switched to <dc:creator> which is the correct element for human-readable names—the dc namespace is already declared in the template.

Before: <author>John Doe</author>
After: <dc:creator>John Doe</dc:creator>

2. Fix double-encoded HTML entities in title/description (Python)

MkDocs pre-escapes page titles and descriptions, then Jinja's |e filter escapes them again, producing &amp;amp;, &amp;lt;, &amp;gt; instead of &amp;, &lt;, &gt;.

Fixed by unescaping in Python (html.unescape()) before passing to the template, so Jinja's |e performs a single correct escape. This is cleaner than template-level workarounds and benefits both RSS and JSON feeds.

Before: &amp;amp; (double-encoded)
After: &amp; (correctly encoded)

3. Guard <enclosure> against None/non-positive length (template)

When the plugin fetches a remote image that returns 404, the length field becomes None, producing invalid XML like <enclosure length="None" />. Added a guard to skip the enclosure element when length is None or non-positive.

Before: {% if item.image is not none %}
After: {% if item.image is not none and item.image[2] is not none and item.image[2] > 0 %}

Tests

Added tests/test_rss_validation.py with three tests covering all fixes:

  • test_dc_creator_instead_of_author
  • test_no_double_encoded_entities
  • test_enclosure_guard_none_length

Plus tests/fixtures/docs/page_with_special_chars.md fixture with & < > characters.

Impact

  • Non-breaking: <dc:creator> is a standard RSS extension already supported by all feed readers
  • Backward compatible: Existing feeds will just use a more correct element
  • Defensive: Prevents invalid XML when remote images fail to load

- Use <dc:creator> instead of <author> for item authors
  RSS 2.0 spec requires <author> to be an email address; the dc namespace
  is already declared and <dc:creator> is the correct element for names.

- Fix double-encoded HTML entities in title and description
  MkDocs pre-escapes content, then Jinja's |e filter escapes again,
  producing &amp;amp;, &amp;lt;, &amp;gt;. Added replace filters to
  correct the double-encoding.

- Guard <enclosure> against None/non-positive length values
  When a remote image returns 404, the length field becomes None,
  producing invalid XML. Added guard to skip enclosure when length
  is None or non-positive.
@github-actions github-actions Bot added the bug Something isn't working label Jul 22, 2026
Zerthick added a commit to DataDelver/datadelver.github.io that referenced this pull request Jul 22, 2026
- Switch to Zerthick/mkdocs-rss-plugin@fix/rss-validation-errors fork
  which includes upstream PR: Guts/mkdocs-rss-plugin#451
- Remove fix_rss_template.py workaround script (no longer needed)
- Remove RSS template patch step from CI workflow

Fixes included in fork:
- <author> -> <dc:creator> for RSS 2.0 compliance
- Guard enclosure length against None values
- Fix double-encoded HTML entities in title/description
@Guts

Guts commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Thanks you and your LLM for this contribution but can you ask it to comply with contributing guidelines please?

Also, are you sure that changes are relevant? Can you share your prompt and give an idea about the level of AI involvement here please?

- Use <dc:creator> instead of <author> for item authors
  RSS 2.0 spec requires <author> to be an email address; the dc namespace
  is already declared and <dc:creator> is the correct element for names.

- Fix double-encoded HTML entities in title/description
  MkDocs pre-escapes content, then Jinja's |e filter escapes again.
  Unescape in Python (html_module.unescape) before template rendering
  so |e performs a single correct escape.

- Guard <enclosure> against None/non-positive length values
  When a remote image returns 404, the length field becomes None,
  producing invalid XML. Added guard to skip enclosure when length
  is None or non-positive.

- Add tests for all three fixes (test_rss_validation.py)
  Includes page_with_special_chars.md fixture with & < > characters.
@Zerthick

Copy link
Copy Markdown
Author

I'm using Material for MkDocs for my own personal blog, I noticed 3 distinct errors in my RSS feed when put in a validator such as: https://www.rssboard.org/rss-validator/

The author issue seems to be a longstanding one: #192 Material for MkDocs typically uses a human readable name for the author, not an email causing validation to fail.

The other two seemed to be edge cases I encountered. Such as having a & character in my article title or an image preview failing to load.

Based on that scale I'd say this is a Level 8 contribution. I did not have a specific prompt, I gave my LLM the errors I was receiving in the validator and told it to resolve them, applied it's fixes, re-validated the feed, until all the errors were resolved.

I can confirm that the forked version is working correctly on my blog now and has resolved the feed and formatting issues I was observing before. https://www.datadelver.com/feed_rss_created.xml

I prompted my LLM to add unit tests, are there any other specific modifications to the PR you would like to see?

@sonarqubecloud

Copy link
Copy Markdown

@Zerthick

Copy link
Copy Markdown
Author

@Guts You can view some of these validation errors on your own feed as well:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working quality Tests, project resiliency, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants