diff --git a/core/lib/Drupal/Core/Block/BlockBase.php b/core/lib/Drupal/Core/Block/BlockBase.php index ef127e99ef010e6106b59a77bb3d6bba1c5b5533..8c97809466099e6737b190d9769b3de7b2721ae4 100644 --- a/core/lib/Drupal/Core/Block/BlockBase.php +++ b/core/lib/Drupal/Core/Block/BlockBase.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Block; use Drupal\block\BlockInterface; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Access\AccessResult; use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Form\FormStateInterface; @@ -166,7 +165,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $form['admin_label'] = array( '#type' => 'item', '#title' => $this->t('Block description'), - '#markup' => SafeMarkup::checkPlain($definition['admin_label']), + '#plain_text' => $definition['admin_label'], ); $form['label'] = array( '#type' => 'textfield', diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php index 69b5b9f5d6efa4a3aae7f212922da37e4940f2d7..3f7393907285577b85668a55663589fc80fcd379 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Field\Plugin\Field\FieldFormatter; use Drupal\Core\Field\FieldItemListInterface; -use Drupal\Component\Utility\SafeMarkup; /** * Plugin implementation of the 'entity reference ID' formatter. @@ -33,7 +32,7 @@ public function viewElements(FieldItemListInterface $items) { foreach ($this->getEntitiesToView($items) as $delta => $entity) { if ($entity->id()) { $elements[$delta] = array( - '#markup' => SafeMarkup::checkPlain($entity->id()), + '#plain_text' => $entity->id(), // Create a cache tag entry for the referenced entity. In the case // that the referenced entity is deleted, the cache for referring // entities must be cleared. diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php index c362a80ec8856b03e992fd4d30bfb9af84628a82..68d28ad589bd0dd13d34b157e41ca5209a2b1df7 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Field\Plugin\Field\FieldFormatter; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; @@ -98,7 +97,7 @@ public function viewElements(FieldItemListInterface $items) { } } else { - $elements[$delta] = array('#markup' => SafeMarkup::checkPlain($label)); + $elements[$delta] = array('#plain_text' => $label); } $elements[$delta]['#cache']['tags'] = $entity->getCacheTags(); } diff --git a/core/modules/block/src/BlockListBuilder.php b/core/modules/block/src/BlockListBuilder.php index 43d7a1c7aadb2d8faa9ec393fe98135df6fa908e..c0a3b2e44af5e86fe08d3f331cc606ff70d2c731 100644 --- a/core/modules/block/src/BlockListBuilder.php +++ b/core/modules/block/src/BlockListBuilder.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Serialization\Json; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Config\Entity\ConfigEntityListBuilder; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; @@ -261,7 +260,7 @@ protected function buildBlocksForm() { $form[$entity_id]['#attributes']['class'][] = 'js-block-placed'; } $form[$entity_id]['info'] = array( - '#markup' => SafeMarkup::checkPlain($info['label']), + '#plain_text' => $info['label'], '#wrapper_attributes' => array( 'class' => array('block'), ), diff --git a/core/modules/block/src/Tests/BlockInterfaceTest.php b/core/modules/block/src/Tests/BlockInterfaceTest.php index 5e8b54c5766d8a2b0a9d1736c0cfefd01c057faa..7215765cc26c166d08e1800776aa42cc5fddd95e 100644 --- a/core/modules/block/src/Tests/BlockInterfaceTest.php +++ b/core/modules/block/src/Tests/BlockInterfaceTest.php @@ -8,7 +8,6 @@ namespace Drupal\block\Tests; use Drupal\Core\Cache\Cache; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Form\FormState; use Drupal\simpletest\KernelTestBase; use Drupal\block\BlockInterface; @@ -73,7 +72,7 @@ public function testBlockInterface() { 'admin_label' => array( '#type' => 'item', '#title' => t('Block description'), - '#markup' => SafeMarkup::checkPlain($definition['admin_label']), + '#plain_text' => $definition['admin_label'], ), 'label' => array( '#type' => 'textfield', diff --git a/core/modules/contact/src/MessageViewBuilder.php b/core/modules/contact/src/MessageViewBuilder.php index 24f58f566bb8e4b4b507095556a76db729fca23e..def70f9a51dd1b427f66fa804bc00aa9c10d56a4 100644 --- a/core/modules/contact/src/MessageViewBuilder.php +++ b/core/modules/contact/src/MessageViewBuilder.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityViewBuilder; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Mail\MailFormatHelper; use Drupal\Core\Render\Element; @@ -42,7 +41,7 @@ public function buildComponents(array &$build, array $entities, array $displays, $build[$id]['message'] = array( '#type' => 'item', '#title' => t('Message'), - '#markup' => SafeMarkup::checkPlain($entity->getMessage()), + '#plain_text' => $entity->getMessage(), ); } } diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 5623f75988935288b5c2644c54cb6191b95f1d49..cea6b2ed37106250efff64dedd492e53dfadfea1 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -5,7 +5,6 @@ * The content translation administration forms. */ -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Config\Entity\ThirdPartySettingsInterface; use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityTypeInterface; @@ -216,10 +215,10 @@ function _content_translation_preprocess_language_content_settings_table(&$varia 'bundle' => array( '#prefix' => '', '#suffix' => ' ', - '#markup' => SafeMarkup::checkPlain($element[$bundle]['settings']['#label']), + '#plain_text' => $element[$bundle]['settings']['#label'], ), 'field' => array( - '#markup' => SafeMarkup::checkPlain($field_element['#label']), + '#plain_text' => $field_element['#label'], ), ), 'class' => array('field'), @@ -250,15 +249,15 @@ function _content_translation_preprocess_language_content_settings_table(&$varia 'bundle' => array( '#prefix' => '', '#suffix' => ' ', - '#markup' => SafeMarkup::checkPlain($element[$bundle]['settings']['#label']), + '#plain_text' => $element[$bundle]['settings']['#label'], ), 'field' => array( '#prefix' => '', '#suffix' => ' ', - '#markup' => SafeMarkup::checkPlain($field_element['#label']), + '#plain_text' => $field_element['#label'], ), 'columns' => array( - '#markup' => SafeMarkup::checkPlain($column_label), + '#plain_text' => $column_label, ), ), 'class' => array('column'), diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php index c89776445d163e06d0bf4b24a2709fe17e915c70..6bdbd26d91ff3401368e59d3bfd2ea9f683a65d0 100644 --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php @@ -174,7 +174,7 @@ public function testIdFormatter() { $formatter = 'entity_reference_entity_id'; $build = $this->buildRenderArray([$this->referencedEntity, $this->unsavedReferencedEntity], $formatter); - $this->assertEqual($build[0]['#markup'], $this->referencedEntity->id(), sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter)); + $this->assertEqual($build[0]['#plain_text'], $this->referencedEntity->id(), sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter)); $this->assertEqual($build[0]['#cache']['tags'], $this->referencedEntity->getCacheTags(), sprintf('The %s formatter has the expected cache tags.', $formatter)); $this->assertTrue(!isset($build[1]), sprintf('The markup returned by the %s formatter is correct for an item with a unsaved entity.', $formatter)); } @@ -244,7 +244,7 @@ public function testLabelFormatter() { // The second referenced entity is "autocreated", therefore not saved and // lacking any URL info. $expected_item_2 = array( - '#markup' => $this->unsavedReferencedEntity->label(), + '#plain_text' => $this->unsavedReferencedEntity->label(), '#cache' => array( 'contexts' => [ 'user.permissions', @@ -257,8 +257,8 @@ public function testLabelFormatter() { // Test with the 'link' setting set to FALSE. $build = $this->buildRenderArray([$this->referencedEntity, $this->unsavedReferencedEntity], $formatter, array('link' => FALSE)); - $this->assertEqual($build[0]['#markup'], $this->referencedEntity->label(), sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter)); - $this->assertEqual($build[1]['#markup'], $this->unsavedReferencedEntity->label(), sprintf('The markup returned by the %s formatter is correct for an item with a unsaved entity.', $formatter)); + $this->assertEqual($build[0]['#plain_text'], $this->referencedEntity->label(), sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter)); + $this->assertEqual($build[1]['#plain_text'], $this->unsavedReferencedEntity->label(), sprintf('The markup returned by the %s formatter is correct for an item with a unsaved entity.', $formatter)); // Test an entity type that doesn't have any link templates, which means // \Drupal\Core\Entity\EntityInterface::urlInfo() will throw an exception @@ -273,7 +273,7 @@ public function testLabelFormatter() { $referenced_entity_with_no_link_template->save(); $build = $this->buildRenderArray([$referenced_entity_with_no_link_template], $formatter, array('link' => TRUE)); - $this->assertEqual($build[0]['#markup'], $referenced_entity_with_no_link_template->label(), sprintf('The markup returned by the %s formatter is correct for an entity type with no valid link template.', $formatter)); + $this->assertEqual($build[0]['#plain_text'], $referenced_entity_with_no_link_template->label(), sprintf('The markup returned by the %s formatter is correct for an entity type with no valid link template.', $formatter)); } /** diff --git a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php index b2275d0dcdae43ecc34c4ed8e009111f661afd70..e80707316c199ed2c16d09fccb5fb7e1faebd7bc 100644 --- a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php @@ -10,7 +10,6 @@ use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Utility\Html; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityWithPluginCollectionInterface; @@ -290,7 +289,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, arr 'defaultPlugin' => $this->getDefaultPlugin($field_definition->getType()), ), 'human_name' => array( - '#markup' => SafeMarkup::checkPlain($label), + '#plain_text' => $label, ), 'weight' => array( '#type' => 'textfield', diff --git a/core/modules/image/src/Form/ImageStyleEditForm.php b/core/modules/image/src/Form/ImageStyleEditForm.php index b07090b7c498d6a9cd35f109be0ad3296b233299..d17a12958c2fe3348fb92c13ff48b2fc349cb578 100644 --- a/core/modules/image/src/Form/ImageStyleEditForm.php +++ b/core/modules/image/src/Form/ImageStyleEditForm.php @@ -12,7 +12,6 @@ use Drupal\Core\Url; use Drupal\image\ConfigurableImageEffectInterface; use Drupal\image\ImageEffectManager; -use Drupal\Component\Utility\SafeMarkup; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -99,7 +98,7 @@ public function form(array $form, FormStateInterface $form_state) { '#tree' => FALSE, 'data' => array( 'label' => array( - '#markup' => SafeMarkup::checkPlain($effect->label()), + '#plain_text' => $effect->label(), ), ), ); diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index 8c35c6bf848ba766642b9cbbf57accea50b83083..3f860de03ff537d9dacef2aa884fc86fa050abb6 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -5,7 +5,6 @@ * Administration functions for language.module. */ -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Render\Element; use Drupal\Core\Template\Attribute; use Drupal\Core\Url; @@ -170,7 +169,7 @@ function template_preprocess_language_content_settings_table(&$variables) { 'data' => array( '#prefix' => '', - '#markup' => SafeMarkup::checkPlain($element[$bundle]['settings']['#label']), + '#plain_text' => $element[$bundle]['settings']['#label'], ), 'class' => array('bundle'), ), diff --git a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php index eb3804a25fc94d44038b2e8393948a40f39b3e76..ed80376ca223482d30710ca17b84b49f8bd7ae99 100644 --- a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php +++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php @@ -7,7 +7,6 @@ namespace Drupal\link\Plugin\Field\FieldFormatter; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Field\FieldDefinitionInterface; @@ -201,7 +200,7 @@ public function viewElements(FieldItemListInterface $items) { if (!empty($settings['url_only']) && !empty($settings['url_plain'])) { $element[$delta] = array( - '#markup' => SafeMarkup::checkPlain($link_title), + '#plain_text' => $link_title, ); if (!empty($item->_attributes)) { diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php index e3a587c245dda9fc908951f883f533154f7916fd..2d3a5b0fd77739dd67a79ce2565a3bcfd529ef05 100644 --- a/core/modules/rest/src/Plugin/views/display/RestExport.php +++ b/core/modules/rest/src/Plugin/views/display/RestExport.php @@ -7,7 +7,6 @@ namespace Drupal\rest\Plugin\views\display; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableResponse; use Drupal\Core\Render\RenderContext; @@ -318,11 +317,12 @@ public function render() { $this->view->element['#content_type'] = $this->getMimeType(); $this->view->element['#cache_properties'][] = '#content_type'; - // Wrap the output in a pre tag if this is for a live preview. + // Encode and wrap the output in a pre tag if this is for a live preview. if (!empty($this->view->live_preview)) { $build['#prefix'] = '
'; - $build['#markup'] = SafeMarkup::checkPlain($build['#markup']); + $build['#plain_text'] = $build['#markup']; $build['#suffix'] = ''; + unset($build['#markup']); } elseif ($this->view->getRequest()->getFormat($this->view->element['#content_type']) !== 'html') { // This display plugin is primarily for returning non-HTML formats. diff --git a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php index de114d43bae787d51ccc2cdbd9951b2f0d377d68..498942f6bf2254909e2f6f2a747dec33d0614a8d 100644 --- a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php +++ b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php @@ -480,16 +480,16 @@ public function testLivePreview() { $entities[] = $row->_entity; } - $expected = Html::escape($serializer->serialize($entities, 'json')); + $expected = $serializer->serialize($entities, 'json'); $view->live_preview = TRUE; $build = $view->preview(); - $rendered_json = $build['#markup']; - $this->assertEqual($rendered_json, $expected, 'Ensure the previewed json is escaped.'); + $rendered_json = $build['#plain_text']; + $this->assertTrue(!isset($build['#markup']) && $rendered_json == $expected, 'Ensure the previewed json is escaped.'); $view->destroy(); - $expected = Html::escape($serializer->serialize($entities, 'xml')); + $expected = $serializer->serialize($entities, 'xml'); // Change the request format to xml. $view->setDisplay('rest_export_1'); @@ -505,7 +505,7 @@ public function testLivePreview() { $this->executeView($view); $build = $view->preview(); - $rendered_xml = $build['#markup']; + $rendered_xml = $build['#plain_text']; $this->assertEqual($rendered_xml, $expected, 'Ensure we preview xml when we change the request format.'); } diff --git a/core/modules/simpletest/src/Form/SimpletestTestForm.php b/core/modules/simpletest/src/Form/SimpletestTestForm.php index aadc4a9fcdb59608accf03295c54c602a1157310..a46be86c1f7ade34277d67c5c34bbd74e605d408 100644 --- a/core/modules/simpletest/src/Form/SimpletestTestForm.php +++ b/core/modules/simpletest/src/Form/SimpletestTestForm.php @@ -8,7 +8,6 @@ namespace Drupal\simpletest\Form; use Drupal\Component\Utility\SortArray; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\RendererInterface; @@ -179,7 +178,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ); $form['tests'][$class]['description'] = array( '#prefix' => '
', - '#markup' => SafeMarkup::checkPlain(drupal_render_root($output)), + '#plain_text' => drupal_render_root($output), '#suffix' => '', ); } diff --git a/core/modules/views_ui/src/Controller/ViewsUIController.php b/core/modules/views_ui/src/Controller/ViewsUIController.php index bed5aaa882f26d3f799382aaaafdb903f038f5c9..2837508eaf01d69ee24f3dad4219d7df798c4086 100644 --- a/core/modules/views_ui/src/Controller/ViewsUIController.php +++ b/core/modules/views_ui/src/Controller/ViewsUIController.php @@ -7,7 +7,6 @@ namespace Drupal\views_ui\Controller; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Url; use Drupal\views\ViewExecutable; @@ -89,7 +88,7 @@ public function reportFields() { $header = array(t('Field name'), t('Used in')); $rows = array(); foreach ($fields as $field_name => $views) { - $rows[$field_name]['data'][0] = SafeMarkup::checkPlain($field_name); + $rows[$field_name]['data'][0]['data']['#plain_text'] = $field_name; foreach ($views as $view) { $rows[$field_name]['data'][1][] = $this->l($view, new Url('entity.view.edit_form', array('view' => $view))); } diff --git a/core/modules/views_ui/src/ViewListBuilder.php b/core/modules/views_ui/src/ViewListBuilder.php index 16abf608b276bfaeaa42cf31dfc9f34d55a235c7..ece0acfdd3acb0ed701f7a80c9ad46619dd22df7 100644 --- a/core/modules/views_ui/src/ViewListBuilder.php +++ b/core/modules/views_ui/src/ViewListBuilder.php @@ -102,7 +102,7 @@ public function buildRow(EntityInterface $view) { ), 'description' => array( 'data' => array( - '#markup' => SafeMarkup::checkPlain($view->get('description')), + '#plain_text' => $view->get('description'), ), 'class' => array('views-table-filter-text-source'), ),