Wordpress RSS feed showing HTML tags on front page:

10 views
Skip to first unread message

Roz Townsend

unread,
Jun 12, 2024, 9:20:54 AM6/12/24
to Alaveteli Dev
Hello again - this is a different issue to our other thing going on with the RSS feeds in our dev environment, so I thought it was appropriate to open a new thread.

We have a Wordpress RSS feed that displays on the front page. Wordpress wraps the description tag in the RSS feed in CDATA, which I understand is used to render special characters. 

Because of this, the description section on our blog posts is rendering the HTML code as characters on the front page. Is there a way to have the HTML render on the front page while keeping the CDATA that is automatically generated by Wordpress? Screencap for reference:

blog_weird.png

Graeme Porteous

unread,
Jun 24, 2024, 3:24:39 AM6/24/24
to alavet...@googlegroups.com
Looks like this is rendering the frontpage blog posts, in which case the partial used is `app/views/general/_frontpage_blog.html.erb` [1]

If you trust the external content and you want to rendered HTML in the post descriptions, this can be done by changing the line:
<%= post.description %>
to:
<%= raw post.description %>

The alternative is to sanitize tags to stripping all but known-safe tags and attributes, done by:
<%= sanitize post.description %>


--
Graeme Porteous
gra...@mysociety.org


--
You received this message because you are subscribed to the Google Groups "Alaveteli Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alaveteli-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/alaveteli-dev/b9b7df3a-a3ee-4ebd-b75f-35cad56bb3can%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages