Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When creating a feed using Views RSS Feed, titles for items are encoded correctly. When creating a feed using View RSS Feed - Fields, the titles for items are double encoded. For example:
RSS Feed: <title>This "title" contains quotes</title>
RSS Feed - Fields: <title>This &quot;title&quot; contains quotes</title>
Double encoding occurs for quotes and ampersands. I have not tested other entities.
Comment | File | Size | Author |
---|---|---|---|
#3 | views_rss-1829800-title-double-encoded-correct-pathes.patch | 2.13 KB | pbusch |
#2 | views_rss-1829800-title-double-encoded-2.patch | 2.41 KB | jcisio |
Comments
Comment #1
Christian DeLoach CreditAttribution: Christian DeLoach commentedI suspect the issue may be cause partly by theme.inc, line 220:
$variables['rss_feed'] = format_xml_elements(array($rss_feed));
When the title is passed to format_xml_elements() the entities in the title are already encoded. format_xml_elements() encodes the contents of each node using check_plain which likely causes the double encoding.
Any ideas?
Comment #2
jcisio CreditAttribution: jcisio commentedSimilar issue in 6.x-1.x #779760: check_plain runs twice on title. A workaround could be hook_views_rss_item_elements_alter(). However this patch fixes it properly.
Comment #3
pbusch CreditAttribution: pbusch commentedThis patch is correct, the other have wrong pathes.
Comment #4
jcisio CreditAttribution: jcisio commented#3 is basically #2 with -p1 instead of -p6, I'm marking it as RTBC because I think pbusch also tested that patch.
Comment #5
Brian E. Conklin CreditAttribution: Brian E. Conklin commentedI am experiencing this exact issue, however the patch provided does not solve the problem. I believe this post is on the right track. The one extra thing I have is the rss feed - itunes also enabled.
I have also tried using 7.x-2.x-dev and get the same results.
I'm not sure what to do next.
Comment #6
darrick CreditAttribution: darrick commentedThis patch solved this issue for me. I'm also using view_rss:itunes. I had to flush the cache after applying.
Comment #7
idealdesigns CreditAttribution: idealdesigns commentedI bumped into this problem where i wanted to remove html tags and html special characters so i wrote a small article
Views Rss html special characters problem
Comment #8
Brian E. Conklin CreditAttribution: Brian E. Conklin commentedThanks! That solved the problem for me perfectly.
Comment #9
recrit CreditAttribution: recrit commentedThis is a larger issue that affects more than just node title. The double escape happens for any views field handler that sanitizes it's output - ie node title, term name, text fields, node body, etc.
Below is a short term workaround that I have used until a permanent fix is available:
Comment #10
dflitner CreditAttribution: dflitner commented#9 is working for me. Thank you.
Comment #11
davidneedhamHere's another workaround for those who prefer to do this in the theme rather than a custom module. Create a template file for the title field in all views: views-view-field--title.tpl.php:
Naturally you could tweak the name of the tpl.php file if you needed it to affect something other than the title, or override a particular view. Refer to Theme: Information in the Advanced fieldset within your view for a list of options.
Comment #12
Brian E. Conklin CreditAttribution: Brian E. Conklin commentedBrilliant! That worked perfectly and is quite simple. Thank you for posting this solution.
Comment #13
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedThis should be now fixed in the most recent 7.x-2.x-dev version, just pushed to d.o. Please clone from git repo or wait till the dev package is rebuild.
Comment #14.0
(not verified) CreditAttribution: commentedCorrected description with code tags.
Comment #15
Charles BelovComment #16
ladybug_3777 CreditAttribution: ladybug_3777 commentedIs there a .patch file that can be used to apply the fix that is listed in comment #13? I did see this link on the referenced site: http://cgit.drupalcode.org/views_rss/patch/?id=5ab174a44775808a35f552b9c... but it's not an actual .patch file I can run with drush or apply with the patch command. Should I just use that to make my own file or am I missing something obvious?
Comment #17
Rhino-new CreditAttribution: Rhino-new commented> This should be now fixed in the most recent 7.x-2.x-dev version
I'm using the most recent 7.x-2.x-dev version and I get this issue.