I have a video embed field and it displays fine when added to a view. But when I "exclude from display" the field and add the field with "{{ field_video }}" to a custom text field, the video will not display. The outer wrapper is printed but not the field-content div and its contents. Tried 8-1.0 and 8-dev from June 14, 2016. Anyone have this working?

Comments

justindhoffman created an issue. See original summary.

justindhoffman’s picture

Title: Views Exluded Field » Views Excluded Field
Sam152’s picture

Status: Active » Needs work

I can reproduce this. Looking at this now.

Sam152’s picture

Status: Needs work » Fixed

This is a problem in \Drupal\views\Plugin\views\PluginBase::viewsTokenReplace. On line 398, it calls Xss::filterAdmin on the inline template used to generate the markup. The list of tags allowed by that function is:

array('a', 'abbr', 'acronym', 'address', 'article', 'aside', 'b', 'bdi', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'command', 'dd', 'del', 'details', 'dfn', 'div', 'dl', 'dt', 'em', 'figcaption', 'figure', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'mark', 'menu', 'meter', 'nav', 'ol', 'output', 'p', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'small', 'span', 'strong', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', 'tr', 'tt', 'u', 'ul', 'var', 'wbr');

Iframe is not one of them, and thus the video is removed from the output.

This change was introduced in #2466931: Valid Twig syntax is incorrectly escaped in Views rewrites. It looks like they wanted token replacements not to be XSS risks from admins inputting data, but this is a difficult problem as the rendered output from a field formatter is already trusted by nature.

My suggestion? Move away from using views fields for this purpose and find a way to make a view mode of your node look the way you expect. You can also open a bug in the core queue or change the project of this issue if you'd like it looked at further.

Sam152’s picture

Status: Fixed » Closed (works as designed)
justindhoffman’s picture

Thanks. I didn't even notice that the custom text wasn't asking for text format. Nor realize it was limited to that filtering. But that clears that up.

jibran’s picture

My suggestion? Move away from using views fields for this purpose and find a way to make a view mode of your node look the way you expect.

+100 to that and if you are still stuck then you can always override the views field template for this field but this is not recommended at all.