diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php index 7915204e8ad..ddcc1fab1dc 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\display; +use Drupal\Component\Utility\String; use Drupal\views\ViewExecutable; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -86,11 +87,17 @@ class Feed extends PathPluginBase { * Overrides \Drupal\views\Plugin\views\display\PathPluginBase::preview(). */ public function preview() { + $output = $this->view->render(); + if (!empty($this->view->live_preview)) { - return '
' . check_plain($this->view->render()) . ''; + $output = array( + '#prefix' => '
', + '#markup' => String::checkPlain($output), + '#suffix' => '', + ); } - return $this->view->render(); + return $output; } /** diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php index 7f134134c0c..77cc434638f 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php @@ -77,6 +77,21 @@ class PreviewTest extends UITestBase { $this->assertText('Test header text', 'Rendered header text found'); $this->assertText('Test footer text', 'Rendered footer text found.'); $this->assertText('Test empty text', 'Rendered empty text found.'); + + // Test feed preview. + $view = array(); + $view['label'] = $this->randomName(16); + $view['id'] = strtolower($this->randomName(16)); + $view['page[create]'] = 1; + $view['page[title]'] = $this->randomName(16); + $view['page[path]'] = $this->randomName(16); + $view['page[feed]'] = 1; + $view['page[feed_properties][path]'] = $this->randomName(16); + $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); + $this->clickLink(t('Feed')); + $this->drupalPostForm(NULL, array(), t('Update preview')); + $result = $this->xpath('//div[@id="views-live-preview"]/pre'); + $this->assertTrue(strpos($result[0], '