Skip to content

Strip style tags and convert iframe embeds during feed sanitization#624

Merged
akirk merged 1 commit intomainfrom
fix/simplepie-kses
Mar 27, 2026
Merged

Strip style tags and convert iframe embeds during feed sanitization#624
akirk merged 1 commit intomainfrom
fix/simplepie-kses

Conversation

@akirk
Copy link
Copy Markdown
Owner

@akirk akirk commented Mar 27, 2026

Summary

  • WordPress's wp_kses_post (used by SimplePie's sanitizer) strips <style> and <iframe> tags but leaves their text content behind
  • This caused ActivityPub embed CSS to appear as raw text in feed posts (e.g. from cubicgarden.com)
  • YouTube/Vimeo embeds became empty <div> wrappers with no video

Introduces a custom SimplePie sanitizer (SimplePie_Sanitize_KSES) that pre-processes feed content before wp_kses_post:

  • Removes <style> and <script> tags with their content
  • Converts YouTube/Vimeo/Dailymotion <iframe> embeds to plain URLs so WordPress can auto-embed them via oEmbed

Test plan

  • Refetch a feed that contains <style> tags (e.g. cubicgarden.com with ActivityPub embeds) — CSS text should no longer appear in post content
  • Refetch a feed with YouTube iframe embeds (e.g. dri.es) — videos should render as WordPress embeds instead of empty divs

Test in WordPress Playground

WordPress's wp_kses_post strips <style> and <iframe> tags but leaves
their text content behind. This caused ActivityPub embed CSS to appear
as raw text in posts, and YouTube/Vimeo embeds to become empty divs.

Introduces a custom SimplePie sanitizer that pre-processes feed content:
- Removes <style> and <script> tags with their content
- Converts YouTube/Vimeo/Dailymotion iframes to plain URLs for
  WordPress auto-embed (oEmbed)
@akirk akirk merged commit c2ff173 into main Mar 27, 2026
25 checks passed
@akirk akirk deleted the fix/simplepie-kses branch March 27, 2026 18:08
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