Description is double-escaped

Created on 11 July 2025, 20 days ago

Problem/Motivation

After installing this module on a Drupal 10.5.1 site, the contents of the description field in a feed are double-escaped, so the end-user sees the html tags and the formatting is broken.

I believe it may be linked to issue https://www.drupal.org/node/3497758

Background: I use Views' RSS Feed to pass content to Mailchimp. This has worked well for many years. I was hoping to add views_rss for a new project, so I can add an enclosure to submit images to Pinterest.

Steps to reproduce

On a clean install of Drupal 10.5.1, create a single Article node, and a view of Article nodes with a Feed display. Visit the feed's url and the description (which comes from the Body field of the node) is single-escaped, which displays correctly in Mailchimp:

<description>&lt;p&gt;Testing body&lt;/p&gt;</description>

Install views_rss 2.4.0, enable it, and clear caches.

In the feed the description is now double-escaped, which doesn't display correctly in Mailchimp:

<description>&amp;lt;p&amp;gt;Testing body&amp;lt;/p&amp;gt;</description>

+++

I repeated the tests on a clean install of Drupal 10.4.3, which is the last version without the change from issue https://www.drupal.org/node/3497758

The feed is not escaped at all, using CDATA instead:

<description><![CDATA[<p>Testing body</p>]]></description>

After installing views_rss the format stays the same:

<description><![CDATA[<p>Testing body</p>]]></description>

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @davidhk
  • First commit to issue fork.
  • Pipeline finished with Failed
    about 22 hours ago
    Total: 143s
    #561125
  • We're experiencing this issue as well. It looks like 🐛 RSS output is no longer valid XML Fixed added the CDATA tag to the RSS view row template, but renders description without |raw, which means Twig automatically encodes the HTML entities, causing the double-encoding: <![CDATA[ &lt;p&gt;test&lt;/p&gt; ]]>

    I've pushed a merge request that escapes any CDATA tag within description and then renders it using |raw, which should be the correct approach. (This is already done a few lines later with item.value).

    This results in the expected unencoded raw HTML within the CDATA tag:<![CDATA[ &lt;p&gt;test&lt;/p&gt; ]]>

    If the patch works for you as well, please update to RTBC.

  • Pipeline finished with Failed
    about 22 hours ago
    Total: 143s
    #561134
  • Pipeline finished with Success
    about 21 hours ago
    Total: 321s
    #561165
  • 🇳🇱Netherlands idebr

    In the DisplayFeedTest.php the description is only checked for html, but not the CDATA. Can you update the assertion to include the CDATA, since this allows the inner text to be html ?

Production build 0.71.5 2024