Views "unfiltered text" headers/footers strip iframes prior to rendering the text. This goes contrary to the description which reads "Add unrestricted, custom text or markup. This is similar to the custom text field." Users currently must use the "text area" header/footer -- with a formatter that doesn't limit HTML tags -- if they want to include an iframe.

Expected behavior is either:
-- Users should be able to input an iframe into an "unfiltered text" header/footer
-- The descriptive text should be updated to reflect that iframes are not allowed.

Comments

mrweiner created an issue. See original summary.

pieterjanput’s picture

Status: Active » Needs review
StatusFileSize
new611 bytes

I've changed the help of this element. It's either this, or adding iframe as an allowed value to $adminTags which probably has a lot more consequences.

sudheeshps’s picture

Assigned: Unassigned » sudheeshps
Status: Needs review » Reviewed & tested by the community

Applied patch from #2 and was successful

cilefen’s picture

Assigned: sudheeshps » Unassigned
Issue tags: +Documentation
+++ b/core/modules/views/views.views.inc
@@ -66,7 +66,7 @@ function views_views_data() {
+    'help' => t('Add custom text or markup, save for scripts and styles. This is similar to the custom text field.'),

I think either "except for" or "not including" would be more widely understandable as more common phrasing than "save for".

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

Thank you for reviewing this issue!

The automated testing infrastructure tells us whether the patch applies, so we do not need people to review that. It is also not sufficient criteria for the issue to be marked "Reviewed and Tested by the Community".

What we do need people to review is whether the issue has a correct scope, whether it passes the core gates, whether the solution completely fixes the problem without introducing other problems, and whether it's the best solution we can come up with. See the patch review guide for more information.

When you do post a review, be sure to describe what you reviewed and how. This helps other reviewers understand why you considered the issue RTBC (and is considered for issue credit).

Based on #4, setting back to needs work.

sudheeshps’s picture

Assigned: Unassigned » sudheeshps
Status: Needs work » Active
sudheeshps’s picture

Status: Active » Needs review
StatusFileSize
new616 bytes

@cilefen & @lauriii, thanks for the updates.

"not including" fits correctly here, so updating the same.
Added the updated patch for the same.

Please review and let me know

ipwa’s picture

The same issue happens on the text area for rewrite field, iframes get stripped.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Setting to RTBC for #7, this correctly resolves the remark by @cilefen

mrweiner’s picture

Guess I should have included a patch initially for the help text, but wasn't sure if iframe embeds should actually be handled. Thanks y'all.

@ipwa the "rewrite field" issue you're describing should be probably exist in another issue so that it doesn't get lost/can be discussed appropriately.

mrweiner’s picture

Status: Reviewed & tested by the community » Needs work

So, now that I actually read the patch -- does "scripts and styles" actually cover iframes? Which category do they fall under? If I saw the patch help text I think I'd still assume that an iframe should work, especially if I were a site builder.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

m.roma’s picture

This is also an issue in Drupal 7 - and I created an issue for that.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

amerie’s picture

If you need the ability to put an iframe in a view header, here is a custom area plugin we used to do that.

<?php

namespace Drupal\ext_view_area_iframe\Plugin\views\area;

use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\area\TokenizeAreaPluginBase;

/**
 * Views area text handler.
 *
 * @ingroup views_area_handlers
 *
 * @ViewsArea("ext_view_iframe")
 */
class ExtViewIframeArea extends TokenizeAreaPluginBase {

  /**
   * {@inheritdoc}
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['url'] = ['default' => ''];
    $options['height'] = ['default' => 600];
    $options['width'] = ['default' => 800];
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);

    $form['url'] = [
      '#title' => $this->t('URL'),
      '#type' => 'textfield',
      '#default_value' => $this->options['url'],
      '#size' => 60,
      '#maxlength' => 500,
      '#required' => TRUE,
    ];
    $form['height'] = [
      '#title' => $this->t('Height'),
      '#type' => 'number',
      '#default_value' => $this->options['height'],
    ];
    $form['width'] = [
      '#title' => $this->t('Width'),
      '#type' => 'number',
      '#default_value' => $this->options['width'],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function render($empty = FALSE) {
    if (!$empty || !empty($this->options['empty'])) {
      return [
        '#type' => 'inline_template',
        '#template' => '<iframe width="{{ width }}" height="{{ height }}" src="{{ url }}" frameborder="0" style="border:0" allowfullscreen></iframe>',
        '#context' => [
          'height' => $this->options['height'],
          'width' => $this->options['width'],
          'url' => $this->tokenizeValue($this->options['url']),
        ],
      ];
    }

    return [];
  }

}
lendude’s picture

This help text should probably be modelled after the fix in #2654962: Views content rewrite text says "You may include HTML" but actually allows only a subset, the same filtering applies here (without the Twig mention).

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

thomasmurphy’s picture

It would be good if there was documentation around what attributes are stripped by what function, and whether this is configurable.
There is a more limited and achievable issue here just around style attributes
https://www.drupal.org/project/drupal/issues/3109650

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

damienmckenna’s picture

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.