This seems to be the culprit.
$element['value'] = check_plain(htmlspecialchars_decode($element['value'], ENT_QUOTES));

At least the following are missed by htmlspecialchars_decode: ' – “ and ”

Since htmlspecialchars_decode seems to miss a lot of encoded characters and Drupal's check_plain function will double encode without remorse we are left with a problem.

Files: 

Comments

ice5nake’s picture

ice5nake’s picture

Changing

$element['value'] = check_plain(htmlspecialchars_decode($element['value'], ENT_QUOTES));

to

$element['value'] = check_plain(decode_entities($element['value']));

seems to have solved the problem

ice5nake’s picture

Status:Active» Needs review
StatusFileSize
new496 bytes
ice5nake’s picture

My patch to end the double encoding is only working on View Displays setup with style "RSS Feed - Fields" and not on ones with style "RSS Feed".

Is the "RSS Feed" style part of a different module?

richsky’s picture

Issue tags:+7.x, +Double encoding

I have the same problem with 7rc3, outpout ' or & But for all custom rss fields.

I had to overrride theme.inc / template_preprocess_views_view_views_rss and add
ln 710 $value = htmlspecialchars_decode($value, ENT_QUOTES); because of

ln 878 format_xml_elements() that use check plain() that use htmlspecialchars() that reencode the string.

  • maciej.zgadzaj committed 35cde8c on 7.x-2.x
    Issue #1791856 by ice5nake: Certain html entities get double encoded
    
maciej.zgadzaj’s picture

Version:6.x-2.0-rc3» 6.x-2.x-dev
Issue summary:View changes
Status:Needs review» Fixed

Fixed in 6.x-2.x (+ fix's fix) and 7.x-2.x.

Status:Fixed» Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

esolitos’s picture

Version:6.x-2.x-dev» 7.x-2.0-rc4
Status:Closed (fixed)» Active

I'm not sure if it's related, but I get an error with my feed that seems related to this.
The feed URL is: http://journalisten.no/feed/rss.xml

In the views preview I get the following code, which shows that å (html entity: å) is double encoded as å, which I think it should be ok, since in xml the entity å is not defined, but as you can observe in the feed i linked above this leads to some encoding issues! (PS: the same goes for ø, which is ø )

<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="http://journalisten.no/feed/rss.xml" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Journalisten Feed</title>
    <link>http://journalisten.no/feed/rss.xml</link>
    <description>Journalisten.no Strøm</description>
    <language>nb</language>
          <item>
    <title>Einar Tho ny sjefredaktør i Haugesunds Avis</title>
    <link>http://journalisten.no/2015/04/einar-tho-ny-sjefredaktor-i-haugesunds-avis</link>
    <description>Vil forvalte avisens posisjon mer enn &amp;aring; revolusjonere.
</description>
     <pubDate>Wed, 15 Apr 2015 09:44:01 +0200</pubDate>
<dc:creator>Glenn Slydal Johansen</dc:creator>
<guid isPermaLink="true">http://journalisten.no/2015/04/einar-tho-ny-sjefredaktor-i-haugesunds-avis</guid>
  </item>
  <item>
    <title>Ingen NJ-krise</title>
    <link>http://journalisten.no/2015/04/ingen-nj-krise</link>
    <description>KOMMENTAR: Det er forst&amp;aring;elig at VG- og Aftenpostenklubbene er skuffet over valgene p&amp;aring; NJ-landsm&amp;oslash;tet, men valgene er ikke uttrykk for noen dyptgripende kulturkonflikt i NJ.
</description>
     <pubDate>Wed, 15 Apr 2015 07:02:11 +0200</pubDate>
<dc:creator>Pål Hellesnes</dc:creator>
<guid isPermaLink="true">http://journalisten.no/2015/04/ingen-nj-krise</guid>
  </item>
  <item>
    <title>TV taper reklamekroner</title>
    <link>http://journalisten.no/2015/04/tv-taper-reklamekroner</link>
    <description>Mediacoms TV-sjef forklarer nedgang med NRK og vintersuksesser som &amp;laquo;Anno&amp;raquo;.
</description>
     <pubDate>Tue, 14 Apr 2015 22:01:00 +0200</pubDate>
<dc:creator>Glenn Slydal Johansen</dc:creator>
<guid isPermaLink="true">http://journalisten.no/2015/04/tv-taper-reklamekroner</guid>
  </item>
[...CUT...]

I have other feeds served by the same situation, but this view seems to be the only one giving me troubles.
Any suggestions?

renzomb’s picture

I have the same problem esolitos, i want to put some custom analytics with the & and the feed encoded is broken, It shows me & and that doesnt work for me, Did u solve this? . I see that in views rss code $value have decode_entities function but doesnt work, i keep watching this to find a solution.

renzomb’s picture

Well, i fixed this with:

<?php
 
function crvt_rss_url_helper_preprocess_views_view_views_rss(&$variables) {
  if (!empty(
$variables['rss_feed'])) {
   
$variables['rss_feed'] = strtr($variables['rss_feed'], array(
     
'&amp;' => '&',
    ));
  }
}
?>