diff --git a/core/modules/views_ui/src/Tests/HandlerTest.php b/core/modules/views_ui/src/Tests/HandlerTest.php index c53ddd7..ffc1efd 100644 --- a/core/modules/views_ui/src/Tests/HandlerTest.php +++ b/core/modules/views_ui/src/Tests/HandlerTest.php @@ -8,6 +8,8 @@ namespace Drupal\views_ui\Tests; use Drupal\Component\Utility\SafeMarkup; +use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\views\ViewExecutable; /** @@ -23,7 +25,7 @@ class HandlerTest extends UITestBase { * * @var array */ - public static $testViews = array('test_view_empty', 'test_view_broken'); + public static $testViews = array('test_view_empty', 'test_view_broken', 'node'); /** * Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition(). @@ -137,6 +139,40 @@ public function testUICRUD() { $this->assertTrue(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was added to the view itself.'); } + public function testHandlerHelpEscaping() { + // Setup a field with two instances using a different label. + // Ensure that the label is escaped properly. + + $this->drupalCreateContentType(['type' => 'article']); + $this->drupalCreateContentType(['type' => 'page']); + + $field_storage = FieldStorageConfig::create([ + 'field_name' => 'field_test', + 'entity_type' => 'node', + 'type' => 'string', + ]); + $field_storage->save(); + + $field_config = FieldConfig::create([ + 'field_name' => 'field_test', + 'entity_type' => 'node', + 'bundle' => 'page', + 'label' => 'The giraffe" label' + ]); + $field_config->save(); + + $field_config = FieldConfig::create([ + 'field_name' => 'field_test', + 'entity_type' => 'node', + 'bundle' => 'article', + 'label' => 'The giraffe" label ' + ]); + $field_config->save(); + + $this->drupalGet('admin/structure/views/nojs/add-handler/content/default/field'); + $this->assertText('Appears in: page, article. Also known as: Content: The giraffe" label alert("the return of the xss")'); + } + /** * Tests broken handlers. */