Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 303301

RSS output not valid when using Twig debug

$
0
0

When twig debug is turned on the theme hook suggestions are inserted in the templates.
However the insertion of the comments breaks the XML standard.

Implications
---------------
The feed does display with comments in the Views preview pane. However the situation is not ideal as the RSS feed is rejected by many external tools. In particular a developer cannot test integration with third-party services such as IFTTT.

Furthermore the transformRootRelativeUrlsToAbsolute step gets skipped so the feed may contain relative URLs.

Steps to reproduce
---------------

  1. create a new drupal project
  2. turn on twig debug
  3. visit the default frontpage feed page (/rss.xml)

Example current feed contents
--------

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_rss' -->
<!-- BEGIN OUTPUT from 'core/themes/classy/templates/views/views-view-rss.html.twig' -->
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xml:base="http://drupal8rsstwigerror.dd:8083/rss.xml" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Drupal 8</title>
    <link>http://drupal8rsstwigerror.dd:8083/rss.xml</link>
    <description></description>
    <language>en</language>
    
    
  </channel>
</rss>

<!-- END OUTPUT from 'core/themes/classy/templates/views/views-view-rss.html.twig' -->

Proposal
------
It is the initial comments before the xml tag that cause the problem. The feed should work if these were moved after the xml tag. The new code should only run if twig debug is enabled.


Viewing all articles
Browse latest Browse all 303301

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>