diff --git a/core/modules/system/src/Tests/Ajax/DialogTest.php b/core/modules/system/src/Tests/Ajax/DialogTest.php index 37bf06c..6654ba2 100644 --- a/core/modules/system/src/Tests/Ajax/DialogTest.php +++ b/core/modules/system/src/Tests/Ajax/DialogTest.php @@ -174,6 +174,7 @@ public function testDialog() { ]; $this->assertEqual($expected_ajax_settings, $ajax_result[0]['settings']['ajax']); $this->setRawContent($ajax_result[3]['data']); + // Remove the data, the form build id and token will never match. unset($ajax_result[3]['data']); $form = $this->xpath("//form[@id='ajax-test-form']"); diff --git a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php index 3704f15..5d1a33b 100644 --- a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php +++ b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; +use Symfony\Component\HttpFoundation\Response; /** * Dummy form for testing DialogRenderer with _form routes. @@ -71,4 +72,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) {} */ public function validateForm(array &$form, FormStateInterface $form_state) {} + public function preview(array &$form, FormStateInterface $form_state) { + return new Response('#ajax-triggered submit worked!'); + } + } diff --git a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php index cef9bab..d1b9f50 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php @@ -43,7 +43,12 @@ protected function setUp() { */ public function testFeedOutput() { $this->drupalCreateContentType(['type' => 'page']); - $this->drupalCreateNode(); + + // Verify a title with HTML entities is properly escaped. + $node_title = 'This "cool" & "neat" article\'s title'; + $this->drupalCreateNode(array( + 'title' => $node_title + )); // Test the site name setting. $site_name = $this->randomMachineName(); @@ -51,6 +56,7 @@ public function testFeedOutput() { $this->drupalGet('test-feed-display.xml'); $result = $this->xpath('//title'); + $this->assertEqual($result[1], $node_title, 'Node title with HTML entities displays correctly.'); $this->assertEqual($result[0], $site_name, 'The site title is used for the feed title.'); $view = $this->container->get('entity.manager')->getStorage('view')->load('test_display_feed'); @@ -74,4 +80,21 @@ public function testFeedOutput() { $this->assertTrue(strpos($feed_icon[0]['href'], 'test-feed-display.xml'), 'The feed icon was found.'); } + /** + * Tests the rendered output for fields display. + */ + public function testFeedFieldOutput() { + $this->drupalCreateContentType(['type' => 'page']); + + // Verify a title with HTML entities is properly escaped. + $node_title = 'This "cool" & "neat" article\'s title'; + $this->drupalCreateNode(array( + 'title' => $node_title + )); + + $this->drupalGet('test-feed-display-fields.xml'); + $result = $this->xpath('//title/a'); + $this->assertEqual($result[0], $node_title, 'Node title with HTML entities displays correctly.'); + } + } diff --git a/core/modules/views/templates/views-view-row-rss.html.twig b/core/modules/views/templates/views-view-row-rss.html.twig index e07244c..6b58a5b 100644 --- a/core/modules/views/templates/views-view-row-rss.html.twig +++ b/core/modules/views/templates/views-view-row-rss.html.twig @@ -14,9 +14,16 @@ * @ingroup themeable */ #} - - {{ title }} - {{ link }} - {{ description }} - {{ item_elements }} - + + {{ title }} + {{ link }} + {{ description }} + {% for item in item_elements -%} + <{{ item.key }}{{ item.attributes -}} + {% if item.value -%} + >{{ item.value }} + {% else -%} + {{ ' />' }} + {% endif %} + {%- endfor %} + diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_display_feed.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_display_feed.yml index a88f655..4c178a1 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_display_feed.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_display_feed.yml @@ -95,6 +95,33 @@ display: display_title: Feed id: feed_1 position: 0 + feed_2: + display_options: + displays: { } + pager: + type: some + path: test-feed-display-fields.xml + row: + type: rss_fields + options: + title_field: title + link_field: title + description_field: title + creator_field: title + date_field: title + guid_field_options: + guid_field: title + guid_field_is_permalink: true + style: + type: rss + sitename_title: true + field_langcode: '***LANGUAGE_language_content***' + field_langcode_add_to_query: null + display_description: '' + display_plugin: feed + display_title: 'Feed with Fields' + id: feed_2 + position: 0 page: display_options: path: test-feed-display diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index a3d8d4a..630d6eb 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -912,11 +912,16 @@ function template_preprocess_views_view_rss(&$variables) { */ function template_preprocess_views_view_row_rss(&$variables) { $item = $variables['row']; - $variables['title'] = String::checkPlain($item->title); $variables['link'] = $item->link; $variables['description'] = String::checkPlain($item->description); - $variables['item_elements'] = empty($item->elements) ? '' : format_xml_elements($item->elements); + $variables['item_elements'] = array(); + foreach ($item->elements as $element) { + if (isset($element['attributes']) && is_array($element['attributes'])) { + $element['attributes'] = new Attribute($element['attributes']); + } + $variables['item_elements'][] = $element; + } } /**