diff --git a/core/includes/common.inc b/core/includes/common.inc
index 85d5f3a..8c1cfad 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -491,7 +491,7 @@ function _drupal_add_html_head_link($attributes, $header = FALSE) {
 
   if ($header) {
     // Also add a HTTP header "Link:".
-    $href = '<' . SafeMarkup::checkPlain($attributes['href']) . '>;';
+    $href = '<' . Html::escape($attributes['href']) . '>;';
     unset($attributes['href']);
     $element['#attached']['http_header'][] = array('Link',  $href . drupal_http_header_attributes($attributes), TRUE);
   }
@@ -1380,7 +1380,7 @@ function _drupal_flush_css_js() {
  */
 function debug($data, $label = NULL, $print_r = TRUE) {
   // Print $data contents to string.
-  $string = SafeMarkup::checkPlain($print_r ? print_r($data, TRUE) : var_export($data, TRUE));
+  $string = Html::escape($print_r ? print_r($data, TRUE) : var_export($data, TRUE));
 
   // Display values with pre-formatting to increase readability.
   $string = '<pre>' . $string . '</pre>';
diff --git a/core/includes/file.inc b/core/includes/file.inc
index 0740c82..142bd20 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -5,11 +5,11 @@
  * API for handling file uploads and server file management.
  */
 
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Component\Utility\UrlHelper;
 use Drupal\Component\PhpStorage\FileStorage;
 use Drupal\Component\Utility\Bytes;
-use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\File\FileSystem;
 use Drupal\Core\StreamWrapper\PublicStream;
 use Drupal\Core\StreamWrapper\StreamWrapperInterface;
@@ -371,7 +371,7 @@ function file_save_htaccess($directory, $private = TRUE, $force_overwrite = FALS
     return drupal_chmod($htaccess_path, 0444);
   }
   else {
-    $variables = array('%directory' => $directory, '!htaccess' => '<br />' . nl2br(SafeMarkup::checkPlain($htaccess_lines)));
+    $variables = array('%directory' => $directory, '!htaccess' => '<br />' . nl2br(Html::escape($htaccess_lines)));
     \Drupal::logger('security')->error("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <code>!htaccess</code>", $variables);
     return FALSE;
   }
diff --git a/core/includes/update.inc b/core/includes/update.inc
index 8e9a24c..15f27a8 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -9,7 +9,7 @@
  */
 
 use Drupal\Component\Graph\Graph;
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Entity\EntityStorageException;
 use Drupal\Core\Utility\Error;
 
@@ -215,7 +215,7 @@ function update_do_one($module, $number, $dependency_map, &$context) {
     drupal_set_installed_schema_version($module, $number);
   }
 
-  $context['message'] = 'Updating ' . SafeMarkup::checkPlain($module) . ' module';
+  $context['message'] = 'Updating ' . Html::escape($module) . ' module';
 }
 
 /**
diff --git a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php
index 99d8f11..49e4675 100644
--- a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php
+++ b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\Core\Asset;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\State\StateInterface;
 
 /**
@@ -168,7 +168,7 @@ public function render(array $css_assets) {
                 // control browser-caching. IE7 does not support a media type on
                 // the @import statement, so we instead specify the media for
                 // the group on the STYLE tag.
-                $import[] = '@import url("' . SafeMarkup::checkPlain(file_create_url($next_css_asset['data']) . '?' . $query_string) . '");';
+                $import[] = '@import url("' . Html::escape(file_create_url($next_css_asset['data']) . '?' . $query_string) . '");';
                 // Move the outer for loop skip the next item, since we
                 // processed it here.
                 $i = $j;
diff --git a/core/lib/Drupal/Core/EventSubscriber/Fast404ExceptionHtmlSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/Fast404ExceptionHtmlSubscriber.php
index 94a13b5..3f095b0 100644
--- a/core/lib/Drupal/Core/EventSubscriber/Fast404ExceptionHtmlSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/Fast404ExceptionHtmlSubscriber.php
@@ -8,7 +8,7 @@
 namespace Drupal\Core\EventSubscriber;
 
 use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -79,7 +79,7 @@ public function on404(GetResponseForExceptionEvent $event) {
     if ($config->get('fast_404.enabled') && $exclude_paths && !preg_match($exclude_paths, $request->getPathInfo())) {
       $fast_paths = $config->get('fast_404.paths');
       if ($fast_paths && preg_match($fast_paths, $request->getPathInfo())) {
-        $fast_404_html = strtr($config->get('fast_404.html'), ['@path' => SafeMarkup::checkPlain($request->getUri())]);
+        $fast_404_html = strtr($config->get('fast_404.html'), ['@path' => Html::escape($request->getUri())]);
         $response = new Response($fast_404_html, Response::HTTP_NOT_FOUND);
         $event->setResponse($response);
       }
diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index 482c888..443cf73 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -12,6 +12,7 @@
 
 namespace Drupal\Core\Template;
 
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\SafeStringInterface;
 use Drupal\Core\Render\RendererInterface;
@@ -433,7 +434,7 @@ public function escapeFilter(\Twig_Environment $env, $arg, $strategy = 'html', $
       // Drupal only supports the HTML escaping strategy, so provide a
       // fallback for other strategies.
       if ($strategy == 'html') {
-        return SafeMarkup::checkPlain($return);
+        return Html::escape($return);
       }
       return twig_escape_filter($env, $return, $strategy, $charset, $autoescape);
     }
diff --git a/core/lib/Drupal/Core/Utility/token.api.php b/core/lib/Drupal/Core/Utility/token.api.php
index d2d87ed..57a1e6d 100644
--- a/core/lib/Drupal/Core/Utility/token.api.php
+++ b/core/lib/Drupal/Core/Utility/token.api.php
@@ -5,7 +5,7 @@
  * Hooks related to the Token system.
  */
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\user\Entity\User;
 
 /**
@@ -97,7 +97,7 @@ function hook_tokens($type, $tokens, array $data, array $options, \Drupal\Core\R
           break;
 
         case 'title':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($node->getTitle()) : $node->getTitle();
+          $replacements[$original] = $sanitize ? Html::escape($node->getTitle()) : $node->getTitle();
           break;
 
         case 'edit-url':
@@ -107,7 +107,7 @@ function hook_tokens($type, $tokens, array $data, array $options, \Drupal\Core\R
         // Default values for the chained tokens handled below.
         case 'author':
           $account = $node->getOwner() ? $node->getOwner() : User::load(0);
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($account->label()) : $account->label();
+          $replacements[$original] = $sanitize ? Html::escape($account->label()) : $account->label();
           $bubbleable_metadata->addCacheableDependency($account);
           break;
 
diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc
index 3a73f39..5b11466 100644
--- a/core/modules/comment/comment.tokens.inc
+++ b/core/modules/comment/comment.tokens.inc
@@ -5,7 +5,7 @@
  * Builds placeholder replacement tokens for comment-related data.
  */
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Datetime\Entity\DateFormat;
 use Drupal\Core\Render\BubbleableMetadata;
@@ -135,7 +135,7 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM
 
         // Poster identity information for comments.
         case 'hostname':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($comment->getHostname()) : $comment->getHostname();
+          $replacements[$original] = $sanitize ? Html::escape($comment->getHostname()) : $comment->getHostname();
           break;
 
         case 'mail':
@@ -145,7 +145,7 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM
           if ($comment->getOwnerId()) {
             $bubbleable_metadata->addCacheableDependency($comment->getOwner());
           }
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($mail) : $mail;
+          $replacements[$original] = $sanitize ? Html::escape($mail) : $mail;
           break;
 
         case 'homepage':
@@ -161,7 +161,7 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM
           break;
 
         case 'langcode':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($comment->language()->getId()) : $comment->language()->getId();
+          $replacements[$original] = $sanitize ? Html::escape($comment->language()->getId()) : $comment->language()->getId();
           break;
 
         // Comment related URLs.
diff --git a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php
index 666b555..5a12ed9 100644
--- a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php
+++ b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php
@@ -8,7 +8,7 @@
 namespace Drupal\comment\Form;
 
 use Drupal\comment\CommentStorageInterface;
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Form\ConfirmFormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Url;
@@ -100,7 +100,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
         '#type' => 'hidden',
         '#value' => $cid,
         '#prefix' => '<li>',
-        '#suffix' => SafeMarkup::checkPlain($comment->label()) . '</li>'
+        '#suffix' => Html::escape($comment->label()) . '</li>'
       );
       $comment_counter++;
     }
diff --git a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php
index c1f4303..699f223 100644
--- a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php
+++ b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\comment\Tests;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Xss;
 use Drupal\comment\Entity\Comment;
 use Drupal\Core\Render\BubbleableMetadata;
@@ -52,26 +52,26 @@ function testCommentTokenReplacement() {
     // Generate and test sanitized tokens.
     $tests = array();
     $tests['[comment:cid]'] = $comment->id();
-    $tests['[comment:hostname]'] = SafeMarkup::checkPlain($comment->getHostname());
+    $tests['[comment:hostname]'] = Html::escape($comment->getHostname());
     $tests['[comment:author]'] = Xss::filter($comment->getAuthorName());
-    $tests['[comment:mail]'] = SafeMarkup::checkPlain($this->adminUser->getEmail());
+    $tests['[comment:mail]'] = SHtml::escape($this->adminUser->getEmail());
     $tests['[comment:homepage]'] = check_url($comment->getHomepage());
     $tests['[comment:title]'] = Xss::filter($comment->getSubject());
     $tests['[comment:body]'] = $comment->comment_body->processed;
-    $tests['[comment:langcode]'] = SafeMarkup::checkPlain($comment->language()->getId());
+    $tests['[comment:langcode]'] = Html::escape($comment->language()->getId());
     $tests['[comment:url]'] = $comment->url('canonical', $url_options + array('fragment' => 'comment-' . $comment->id()));
     $tests['[comment:edit-url]'] = $comment->url('edit-form', $url_options);
     $tests['[comment:created]'] = \Drupal::service('date.formatter')->format($comment->getCreatedTime(), 'medium', array('langcode' => $language_interface->getId()));
     $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getCreatedTime(), array('langcode' => $language_interface->getId()));
     $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getChangedTimeAcrossTranslations(), array('langcode' => $language_interface->getId()));
     $tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL;
-    $tests['[comment:parent:title]'] = SafeMarkup::checkPlain($parent_comment->getSubject());
-    $tests['[comment:entity]'] = SafeMarkup::checkPlain($node->getTitle());
+    $tests['[comment:parent:title]'] = Html::escape($parent_comment->getSubject());
+    $tests['[comment:entity]'] = Html::escape($node->getTitle());
     // Test node specific tokens.
     $tests['[comment:entity:nid]'] = $comment->getCommentedEntityId();
-    $tests['[comment:entity:title]'] = SafeMarkup::checkPlain($node->getTitle());
+    $tests['[comment:entity:title]'] = Html::escape($node->getTitle());
     $tests['[comment:author:uid]'] = $comment->getOwnerId();
-    $tests['[comment:author:name]'] = SafeMarkup::checkPlain($this->adminUser->getUsername());
+    $tests['[comment:author:name]'] = Html::escape($this->adminUser->getUsername());
 
     $base_bubbleable_metadata = BubbleableMetadata::createFromObject($comment);
     $metadata_tests = [];
diff --git a/core/modules/editor/src/EditorXssFilter/Standard.php b/core/modules/editor/src/EditorXssFilter/Standard.php
index 43ef797..2bab2e8 100644
--- a/core/modules/editor/src/EditorXssFilter/Standard.php
+++ b/core/modules/editor/src/EditorXssFilter/Standard.php
@@ -9,7 +9,6 @@
 
 use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Xss;
-use Drupal\Component\Utility\SafeMarkup;
 use Drupal\filter\FilterFormatInterface;
 use Drupal\editor\EditorXssFilterInterface;
 
@@ -114,7 +113,7 @@ protected static function filterXssDataAttributes($html) {
         // value. There is no need to explicitly decode $node->value, since the
         // DOMAttr::value getter returns the decoded value.
         $value = Xss::filterAdmin($node->value);
-        $node->value = SafeMarkup::checkPlain($value);
+        $node->value = Html::escape($value);
       }
       $html = Html::serialize($dom);
     }
diff --git a/core/modules/editor/src/Tests/EditorSecurityTest.php b/core/modules/editor/src/Tests/EditorSecurityTest.php
index a50b6ab..bb39450 100644
--- a/core/modules/editor/src/Tests/EditorSecurityTest.php
+++ b/core/modules/editor/src/Tests/EditorSecurityTest.php
@@ -9,7 +9,6 @@
 
 use Drupal\Component\Serialization\Json;
 use Drupal\simpletest\WebTestBase;
-use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests XSS protection for content creators when using text editors.
@@ -388,7 +387,6 @@ function testSwitchingSecurity() {
     // Log in as the privileged user, and for every sample, do the following:
     //  - switch to every other text format/editor
     //  - assert the XSS-filtered values that we get from the server
-    $value_original_attribute = SafeMarkup::checkPlain(self::$sampleContent);
     $this->drupalLogin($this->privilegedUser);
     foreach ($expected as $case) {
       $this->drupalGet('node/' . $case['node_id'] . '/edit');
diff --git a/core/modules/field/src/Tests/FormTest.php b/core/modules/field/src/Tests/FormTest.php
index e51cb17..4b8228b 100644
--- a/core/modules/field/src/Tests/FormTest.php
+++ b/core/modules/field/src/Tests/FormTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\field\Tests;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\Form\FormState;
 use Drupal\field\Entity\FieldConfig;
@@ -105,7 +105,7 @@ function testFieldFormSingle() {
     $this->drupalGet('entity_test/add');
 
     // Create token value expected for description.
-    $token_description = SafeMarkup::checkPlain($this->config('system.site')->get('name')) . '_description';
+    $token_description = Html::escape($this->config('system.site')->get('name')) . '_description';
     $this->assertText($token_description, 'Token replacement for description is displayed');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
     $this->assertNoField("{$field_name}[1][value]", 'No extraneous widget is displayed');
diff --git a/core/modules/field/src/Tests/String/RawStringFormatterTest.php b/core/modules/field/src/Tests/String/RawStringFormatterTest.php
index 82f6973..60ea420 100644
--- a/core/modules/field/src/Tests/String/RawStringFormatterTest.php
+++ b/core/modules/field/src/Tests/String/RawStringFormatterTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\field\Tests\String;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
 use Drupal\Core\Entity\FieldableEntityInterface;
@@ -119,7 +119,7 @@ public function testStringFormatter() {
     // Verify that all HTML is escaped and newlines are retained.
     $this->renderEntityFields($entity, $this->display);
     $this->assertNoRaw($value);
-    $this->assertRaw(nl2br(SafeMarkup::checkPlain($value)));
+    $this->assertRaw(nl2br(Html::escape($value)));
 
     // Verify the cache tags.
     $build = $entity->{$this->fieldName}->view();
diff --git a/core/modules/field/src/Tests/String/StringFormatterTest.php b/core/modules/field/src/Tests/String/StringFormatterTest.php
index dcb515e..1703c3e 100644
--- a/core/modules/field/src/Tests/String/StringFormatterTest.php
+++ b/core/modules/field/src/Tests/String/StringFormatterTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\field\Tests\String;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
 use Drupal\Core\Entity\FieldableEntityInterface;
@@ -119,7 +119,7 @@ public function testStringFormatter() {
     // Verify that all HTML is escaped and newlines are retained.
     $this->renderEntityFields($entity, $this->display);
     $this->assertNoRaw($value);
-    $this->assertRaw(nl2br(SafeMarkup::checkPlain($value)));
+    $this->assertRaw(nl2br(Html::escape($value)));
 
     // Verify the cache tags.
     $build = $entity->{$this->fieldName}->view();
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index c4163e6..6b10665 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -5,6 +5,7 @@
  * Defines a "managed_file" Form API field and a "file" field for Field module.
  */
 
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Datetime\Entity\DateFormat;
 use Drupal\Core\Field\FieldDefinitionInterface;
@@ -968,15 +969,15 @@ function file_tokens($type, $tokens, array $data, array $options, BubbleableMeta
 
         // Essential file data
         case 'name':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($file->getFilename()) : $file->getFilename();
+          $replacements[$original] = $sanitize ? Html::escape($file->getFilename()) : $file->getFilename();
           break;
 
         case 'path':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($file->getFileUri()) : $file->getFileUri();
+          $replacements[$original] = $sanitize ? Html::escape($file->getFileUri()) : $file->getFileUri();
           break;
 
         case 'mime':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($file->getMimeType()) : $file->getMimeType();
+          $replacements[$original] = $sanitize ? Html::escape($file->getMimeType()) : $file->getMimeType();
           break;
 
         case 'size':
@@ -984,7 +985,7 @@ function file_tokens($type, $tokens, array $data, array $options, BubbleableMeta
           break;
 
         case 'url':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain(file_create_url($file->getFileUri())) : file_create_url($file->getFileUri());
+          $replacements[$original] = $sanitize ? Html::escape(file_create_url($file->getFileUri())) : file_create_url($file->getFileUri());
           break;
 
         // These tokens are default variations on the chained tokens handled below.
@@ -1004,7 +1005,7 @@ function file_tokens($type, $tokens, array $data, array $options, BubbleableMeta
           $owner = $file->getOwner();
           $bubbleable_metadata->addCacheableDependency($owner);
           $name = $owner->label();
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($name) : $name;
+          $replacements[$original] = $sanitize ? Html::escape($name) : $name;
           break;
       }
     }
diff --git a/core/modules/file/src/Tests/FileTokenReplaceTest.php b/core/modules/file/src/Tests/FileTokenReplaceTest.php
index 2d289c4..0f771d0 100644
--- a/core/modules/file/src/Tests/FileTokenReplaceTest.php
+++ b/core/modules/file/src/Tests/FileTokenReplaceTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\file\Tests;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Render\BubbleableMetadata;
 use Drupal\file\Entity\File;
 
@@ -47,16 +47,16 @@ function testFileTokenReplacement() {
     // Generate and test sanitized tokens.
     $tests = array();
     $tests['[file:fid]'] = $file->id();
-    $tests['[file:name]'] = SafeMarkup::checkPlain($file->getFilename());
-    $tests['[file:path]'] = SafeMarkup::checkPlain($file->getFileUri());
-    $tests['[file:mime]'] = SafeMarkup::checkPlain($file->getMimeType());
+    $tests['[file:name]'] = Html::escape($file->getFilename());
+    $tests['[file:path]'] = Html::escape($file->getFileUri());
+    $tests['[file:mime]'] = Html::escape($file->getMimeType());
     $tests['[file:size]'] = format_size($file->getSize());
-    $tests['[file:url]'] = SafeMarkup::checkPlain(file_create_url($file->getFileUri()));
+    $tests['[file:url]'] = Html::escape(file_create_url($file->getFileUri()));
     $tests['[file:created]'] = format_date($file->getCreatedTime(), 'medium', '', NULL, $language_interface->getId());
     $tests['[file:created:short]'] = format_date($file->getCreatedTime(), 'short', '', NULL, $language_interface->getId());
     $tests['[file:changed]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->getId());
     $tests['[file:changed:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->getId());
-    $tests['[file:owner]'] = SafeMarkup::checkPlain(user_format_name($this->adminUser));
+    $tests['[file:owner]'] = Html::escape(user_format_name($this->adminUser));
     $tests['[file:owner:uid]'] = $file->getOwnerId();
 
     $base_bubbleable_metadata = BubbleableMetadata::createFromObject($file);
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index c186576..9f289b8 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -631,8 +631,8 @@ function _filter_url_parse_email_links($match) {
   $i = 0;
 
   $match[$i] = Html::decodeEntities($match[$i]);
-  $caption = SafeMarkup::checkPlain(_filter_url_trim($match[$i]));
-  $match[$i] = SafeMarkup::checkPlain($match[$i]);
+  $caption = Html::escape(_filter_url_trim($match[$i]));
+  $match[$i] = Html::escape($match[$i]);
   return '<a href="mailto:' . $match[$i] . '">' . $caption . '</a>';
 }
 
@@ -646,8 +646,8 @@ function _filter_url_parse_partial_links($match) {
   $i = 1;
 
   $match[$i] = Html::decodeEntities($match[$i]);
-  $caption = SafeMarkup::checkPlain(_filter_url_trim($match[$i]));
-  $match[$i] = SafeMarkup::checkPlain($match[$i]);
+  $caption = Html::escape(_filter_url_trim($match[$i]));
+  $match[$i] = Html::escape($match[$i]);
   return '<a href="http://' . $match[$i] . '">' . $caption . '</a>';
 }
 
@@ -778,7 +778,7 @@ function _filter_autop($text) {
  * Escapes all HTML tags, so they will be visible instead of being effective.
  */
 function _filter_html_escape($text) {
-  return trim(SafeMarkup::checkPlain($text));
+  return trim(Html::escape($text));
 }
 
 /**
diff --git a/core/modules/filter/src/Plugin/Filter/FilterCaption.php b/core/modules/filter/src/Plugin/Filter/FilterCaption.php
index e199538..7671452 100644
--- a/core/modules/filter/src/Plugin/Filter/FilterCaption.php
+++ b/core/modules/filter/src/Plugin/Filter/FilterCaption.php
@@ -8,7 +8,6 @@
 namespace Drupal\filter\Plugin\Filter;
 
 use Drupal\Component\Utility\Html;
-use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Component\Utility\Xss;
 use Drupal\filter\FilterProcessResult;
@@ -40,7 +39,7 @@ public function process($text, $langcode) {
       $xpath = new \DOMXPath($dom);
       foreach ($xpath->query('//*[@data-caption]') as $node) {
         // Read the data-caption attribute's value, then delete it.
-        $caption = SafeMarkup::checkPlain($node->getAttribute('data-caption'));
+        $caption = Html::escape($node->getAttribute('data-caption'));
         $node->removeAttribute('data-caption');
 
         // Sanitize caption: decode HTML encoding, limit allowed HTML tags; only
diff --git a/core/modules/filter/src/Tests/FilterUnitTest.php b/core/modules/filter/src/Tests/FilterUnitTest.php
index fe7664c..9bf0fdb 100644
--- a/core/modules/filter/src/Tests/FilterUnitTest.php
+++ b/core/modules/filter/src/Tests/FilterUnitTest.php
@@ -849,10 +849,10 @@ function assertFilteredString($filter, $tests) {
           )));
         }
         if (!$success) {
-          $this->verbose('Source:<pre>' . SafeMarkup::checkPlain(var_export($source, TRUE)) . '</pre>'
-            . '<hr />' . 'Result:<pre>' . SafeMarkup::checkPlain(var_export($result, TRUE)) . '</pre>'
+          $this->verbose('Source:<pre>' . Html::escape(var_export($source, TRUE)) . '</pre>'
+            . '<hr />' . 'Result:<pre>' . Html::escape(var_export($result, TRUE)) . '</pre>'
             . '<hr />' . ($is_expected ? 'Expected:' : 'Not expected:')
-            . '<pre>' . SafeMarkup::checkPlain(var_export($value, TRUE)) . '</pre>'
+            . '<pre>' . Html::escape(var_export($value, TRUE)) . '</pre>'
           );
         }
       }
diff --git a/core/modules/language/src/Form/LanguageFormBase.php b/core/modules/language/src/Form/LanguageFormBase.php
index e3711ed..bbafe0e 100644
--- a/core/modules/language/src/Form/LanguageFormBase.php
+++ b/core/modules/language/src/Form/LanguageFormBase.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\language\Form;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Entity\EntityForm;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Language\LanguageInterface;
@@ -106,7 +106,7 @@ public function validateCommon(array $form, FormStateInterface $form_state) {
         '@url' => 'http://www.w3.org/International/articles/language-tags/',
       )));
     }
-    if ($form_state->getValue('label') != SafeMarkup::checkPlain($form_state->getValue('label'))) {
+    if ($form_state->getValue('label') != Html::escape($form_state->getValue('label'))) {
       $form_state->setErrorByName('label', $this->t('%field cannot contain any markup.', array('%field' => $form['label']['#title'])));
     }
   }
diff --git a/core/modules/link/src/Tests/LinkFieldTest.php b/core/modules/link/src/Tests/LinkFieldTest.php
index 558e78f..b39a2f5 100644
--- a/core/modules/link/src/Tests/LinkFieldTest.php
+++ b/core/modules/link/src/Tests/LinkFieldTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\link\Tests;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Url;
 use Drupal\link\LinkItemInterface;
@@ -420,39 +420,39 @@ function testLinkFormatter() {
           case 'trim_length':
             $url = $url1;
             $title = isset($new_value) ? Unicode::truncate($title1, $new_value, FALSE, TRUE) : $title1;
-            $this->assertRaw('<a href="' . SafeMarkup::checkPlain($url) . '">' . SafeMarkup::checkPlain($title) . '</a>');
+            $this->assertRaw('<a href="' . Html::escape($url) . '">' . Html::escape($title) . '</a>');
 
             $url = $url2;
             $title = isset($new_value) ? Unicode::truncate($title2, $new_value, FALSE, TRUE) : $title2;
-            $this->assertRaw('<a href="' . SafeMarkup::checkPlain($url) . '">' . SafeMarkup::checkPlain($title) . '</a>');
+            $this->assertRaw('<a href="' . Html::escape($url) . '">' . Html::escape($title) . '</a>');
             break;
 
           case 'rel':
             $rel = isset($new_value) ? ' rel="' . $new_value . '"' : '';
-            $this->assertRaw('<a href="' . SafeMarkup::checkPlain($url1) . '"' . $rel . '>' . SafeMarkup::checkPlain($title1) . '</a>');
-            $this->assertRaw('<a href="' . SafeMarkup::checkPlain($url2) . '"' . $rel . '>' . SafeMarkup::checkPlain($title2) . '</a>');
+            $this->assertRaw('<a href="' . Html::escape($url1) . '"' . $rel . '>' . Html::escape($title1) . '</a>');
+            $this->assertRaw('<a href="' . Html::escape($url2) . '"' . $rel . '>' . Html::escape($title2) . '</a>');
             break;
 
           case 'target':
             $target = isset($new_value) ? ' target="' . $new_value . '"' : '';
-            $this->assertRaw('<a href="' . SafeMarkup::checkPlain($url1) . '"' . $target . '>' . SafeMarkup::checkPlain($title1) . '</a>');
-            $this->assertRaw('<a href="' . SafeMarkup::checkPlain($url2) . '"' . $target . '>' . SafeMarkup::checkPlain($title2) . '</a>');
+            $this->assertRaw('<a href="' . Html::escape($url1) . '"' . $target . '>' . Html::escape($title1) . '</a>');
+            $this->assertRaw('<a href="' . Html::escape($url2) . '"' . $target . '>' . Html::escape($title2) . '</a>');
             break;
 
           case 'url_only':
             // In this case, $new_value is an array.
             if (!$new_value['url_only']) {
-              $this->assertRaw('<a href="' . SafeMarkup::checkPlain($url1) . '">' . SafeMarkup::checkPlain($title1) . '</a>');
-              $this->assertRaw('<a href="' . SafeMarkup::checkPlain($url2) . '">' . SafeMarkup::checkPlain($title2) . '</a>');
+              $this->assertRaw('<a href="' . Html::escape($url1) . '">' . Html::escape($title1) . '</a>');
+              $this->assertRaw('<a href="' . Html::escape($url2) . '">' . Html::escape($title2) . '</a>');
             }
             else {
               if (empty($new_value['url_plain'])) {
-                $this->assertRaw('<a href="' . SafeMarkup::checkPlain($url1) . '">' . SafeMarkup::checkPlain($url1) . '</a>');
-                $this->assertRaw('<a href="' . SafeMarkup::checkPlain($url2) . '">' . SafeMarkup::checkPlain($url2) . '</a>');
+                $this->assertRaw('<a href="' . Html::escape($url1) . '">' . Html::escape($url1) . '</a>');
+                $this->assertRaw('<a href="' . Html::escape($url2) . '">' . Html::escape($url2) . '</a>');
               }
               else {
-                $this->assertNoRaw('<a href="' . SafeMarkup::checkPlain($url1) . '">' . SafeMarkup::checkPlain($url1) . '</a>');
-                $this->assertNoRaw('<a href="' . SafeMarkup::checkPlain($url2) . '">' . SafeMarkup::checkPlain($url2) . '</a>');
+                $this->assertNoRaw('<a href="' . Html::escape($url1) . '">' . Html::escape($url1) . '</a>');
+                $this->assertNoRaw('<a href="' . Html::escape($url2) . '">' . Html::escape($url2) . '</a>');
                 $this->assertEscaped($url1);
                 $this->assertEscaped($url2);
               }
@@ -540,7 +540,7 @@ function testLinkSeparateFormatter() {
             $url = $url1;
             $url_title = isset($new_value) ? Unicode::truncate($url, $new_value, FALSE, TRUE) : $url;
             $expected = '<div class="link-item">';
-            $expected .= '<div class="link-url"><a href="' . SafeMarkup::checkPlain($url) . '">' . SafeMarkup::checkPlain($url_title) . '</a></div>';
+            $expected .= '<div class="link-url"><a href="' . Html::escape($url) . '">' . Html::escape($url_title) . '</a></div>';
             $expected .= '</div>';
             $this->assertRaw($expected);
 
@@ -548,22 +548,22 @@ function testLinkSeparateFormatter() {
             $url_title = isset($new_value) ? Unicode::truncate($url, $new_value, FALSE, TRUE) : $url;
             $title = isset($new_value) ? Unicode::truncate($title2, $new_value, FALSE, TRUE) : $title2;
             $expected = '<div class="link-item">';
-            $expected .= '<div class="link-title">' . SafeMarkup::checkPlain($title) . '</div>';
-            $expected .= '<div class="link-url"><a href="' . SafeMarkup::checkPlain($url) . '">' . SafeMarkup::checkPlain($url_title) . '</a></div>';
+            $expected .= '<div class="link-title">' . Html::escape($title) . '</div>';
+            $expected .= '<div class="link-url"><a href="' . Html::escape($url) . '">' . Html::escape($url_title) . '</a></div>';
             $expected .= '</div>';
             $this->assertRaw($expected);
             break;
 
           case 'rel':
             $rel = isset($new_value) ? ' rel="' . $new_value . '"' : '';
-            $this->assertRaw('<div class="link-url"><a href="' . SafeMarkup::checkPlain($url1) . '"' . $rel . '>' . SafeMarkup::checkPlain($url1) . '</a></div>');
-            $this->assertRaw('<div class="link-url"><a href="' . SafeMarkup::checkPlain($url2) . '"' . $rel . '>' . SafeMarkup::checkPlain($url2) . '</a></div>');
+            $this->assertRaw('<div class="link-url"><a href="' . Html::escape($url1) . '"' . $rel . '>' . Html::escape($url1) . '</a></div>');
+            $this->assertRaw('<div class="link-url"><a href="' . Html::escape($url2) . '"' . $rel . '>' . Html::escape($url2) . '</a></div>');
             break;
 
           case 'target':
             $target = isset($new_value) ? ' target="' . $new_value . '"' : '';
-            $this->assertRaw('<div class="link-url"><a href="' . SafeMarkup::checkPlain($url1) . '"' . $target . '>' . SafeMarkup::checkPlain($url1) . '</a></div>');
-            $this->assertRaw('<div class="link-url"><a href="' . SafeMarkup::checkPlain($url2) . '"' . $target . '>' . SafeMarkup::checkPlain($url2) . '</a></div>');
+            $this->assertRaw('<div class="link-url"><a href="' . Html::escape($url1) . '"' . $target . '>' . Html::escape($url1) . '</a></div>');
+            $this->assertRaw('<div class="link-url"><a href="' . Html::escape($url2) . '"' . $target . '>' . Html::escape($url2) . '</a></div>');
             break;
         }
       }
diff --git a/core/modules/locale/src/Form/TranslateEditForm.php b/core/modules/locale/src/Form/TranslateEditForm.php
index bac65c7..e9c5359 100644
--- a/core/modules/locale/src/Form/TranslateEditForm.php
+++ b/core/modules/locale/src/Form/TranslateEditForm.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\locale\Form;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Render\Element;
 use Drupal\locale\SourceString;
@@ -73,7 +73,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
             '#type' => 'item',
             '#title' => $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))),
             '#title_display' => 'invisible',
-            '#markup' => '<span lang="en">' . SafeMarkup::checkPlain($source_array[0]) . '</span>',
+            '#markup' => '<span lang="en">' . Html::escape($source_array[0]) . '</span>',
           );
         }
         else {
@@ -82,13 +82,13 @@ public function buildForm(array $form, FormStateInterface $form_state) {
           $original_singular = [
             '#type' => 'item',
             '#title' => $this->t('Singular form'),
-            '#markup' => '<span lang="en">' . SafeMarkup::checkPlain($source_array[0]) . '</span>',
+            '#markup' => '<span lang="en">' . Html::escape($source_array[0]) . '</span>',
             '#prefix' => '<span class="visually-hidden">' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . '</span>',
           ];
           $original_plural = [
             '#type' => 'item',
             '#title' => $this->t('Plural form'),
-            '#markup' => '<span lang="en">' . SafeMarkup::checkPlain($source_array[1]) . '</span>',
+            '#markup' => '<span lang="en">' . Html::escape($source_array[1]) . '</span>',
           ];
           $form['strings'][$string->lid]['original'] = [
             $original_singular,
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index fc45df4..132f72a 100644
--- a/core/modules/node/node.api.php
+++ b/core/modules/node/node.api.php
@@ -1,7 +1,7 @@
 <?php
 
 use Drupal\node\NodeInterface;
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Access\AccessResult;
 
@@ -403,7 +403,7 @@ function hook_node_update_index(\Drupal\node\NodeInterface $node, $langcode) {
   $text = '';
   $ratings = db_query('SELECT title, description FROM {my_ratings} WHERE nid = :nid', array(':nid' => $node->id()));
   foreach ($ratings as $rating) {
-    $text .= '<h2>' . SafeMarkup::checkPlain($rating->title) . '</h2>' . Xss::filter($rating->description);
+    $text .= '<h2>' . Html::escape($rating->title) . '</h2>' . Xss::filter($rating->description);
   }
   return $text;
 }
diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc
index 1bba0cc..3294044 100644
--- a/core/modules/node/node.tokens.inc
+++ b/core/modules/node/node.tokens.inc
@@ -5,7 +5,7 @@
  * Builds placeholder replacement tokens for node-related data.
  */
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Datetime\Entity\DateFormat;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Core\Render\BubbleableMetadata;
@@ -116,16 +116,16 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta
           break;
 
         case 'type':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($node->getType()) : $node->getType();
+          $replacements[$original] = $sanitize ? Html::escape($node->getType()) : $node->getType();
           break;
 
         case 'type-name':
           $type_name = node_get_type_label($node);
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($type_name) : $type_name;
+          $replacements[$original] = $sanitize ? Html::escape($type_name) : $type_name;
           break;
 
         case 'title':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($node->getTitle()) : $node->getTitle();
+          $replacements[$original] = $sanitize ? Html::escape($node->getTitle()) : $node->getTitle();
           break;
 
         case 'body':
@@ -164,7 +164,7 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta
           break;
 
         case 'langcode':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($node->language()->getId()) : $node->language()->getId();
+          $replacements[$original] = $sanitize ? Html::escape($node->language()->getId()) : $node->language()->getId();
           break;
 
         case 'url':
@@ -179,7 +179,7 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta
         case 'author':
           $account = $node->getOwner() ? $node->getOwner() : User::load(0);
           $bubbleable_metadata->addCacheableDependency($account);
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($account->label()) : $account->label();
+          $replacements[$original] = $sanitize ? Html::escape($account->label()) : $account->label();
           break;
 
         case 'created':
diff --git a/core/modules/node/src/Tests/NodeTokenReplaceTest.php b/core/modules/node/src/Tests/NodeTokenReplaceTest.php
index 9bfbdb4..3ec91d9 100644
--- a/core/modules/node/src/Tests/NodeTokenReplaceTest.php
+++ b/core/modules/node/src/Tests/NodeTokenReplaceTest.php
@@ -7,9 +7,9 @@
 
 namespace Drupal\node\Tests;
 
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Render\BubbleableMetadata;
 use Drupal\system\Tests\System\TokenReplaceUnitTestBase;
-use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Generates text using placeholders for dummy content to check node token
@@ -65,15 +65,15 @@ function testNodeTokenReplacement() {
     $tests['[node:vid]'] = $node->getRevisionId();
     $tests['[node:type]'] = 'article';
     $tests['[node:type-name]'] = 'Article';
-    $tests['[node:title]'] = SafeMarkup::checkPlain($node->getTitle());
+    $tests['[node:title]'] = Html::escape($node->getTitle());
     $tests['[node:body]'] = $node->body->processed;
     $tests['[node:summary]'] = $node->body->summary_processed;
-    $tests['[node:langcode]'] = SafeMarkup::checkPlain($node->language()->getId());
+    $tests['[node:langcode]'] = Html::escape($node->language()->getId());
     $tests['[node:url]'] = $node->url('canonical', $url_options);
     $tests['[node:edit-url]'] = $node->url('edit-form', $url_options);
-    $tests['[node:author]'] = SafeMarkup::checkPlain($account->getUsername());
+    $tests['[node:author]'] = Html::escape($account->getUsername());
     $tests['[node:author:uid]'] = $node->getOwnerId();
-    $tests['[node:author:name]'] = SafeMarkup::checkPlain($account->getUsername());
+    $tests['[node:author:name]'] = Html::escape($account->getUsername());
     $tests['[node:created:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($node->getCreatedTime(), array('langcode' => $this->interfaceLanguage->getId()));
     $tests['[node:changed:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($node->getChangedTime(), array('langcode' => $this->interfaceLanguage->getId()));
 
diff --git a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
index a0f482a..de114d4 100644
--- a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
+++ b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\rest\Tests\Views;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Cache\Cache;
 use Drupal\entity_test\Entity\EntityTest;
 use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
@@ -480,7 +480,7 @@ public function testLivePreview() {
       $entities[] = $row->_entity;
     }
 
-    $expected = SafeMarkup::checkPlain($serializer->serialize($entities, 'json'));
+    $expected = Html::escape($serializer->serialize($entities, 'json'));
 
     $view->live_preview = TRUE;
 
@@ -489,7 +489,7 @@ public function testLivePreview() {
     $this->assertEqual($rendered_json, $expected, 'Ensure the previewed json is escaped.');
     $view->destroy();
 
-    $expected = SafeMarkup::checkPlain($serializer->serialize($entities, 'xml'));
+    $expected = Html::escape($serializer->serialize($entities, 'xml'));
 
     // Change the request format to xml.
     $view->setDisplay('rest_export_1');
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index 14ecb23..3ffa639 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -5,7 +5,6 @@
  * Enables site-wide keyword searching.
  */
 
-use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Cache\Cache;
@@ -767,7 +766,7 @@ function search_excerpt($keys, $text, $langcode = NULL) {
   // translated. Let translators have the … separator text as one chunk.
   $ellipses = explode('!excerpt', t('… !excerpt … !excerpt …'));
   $text = (isset($new_ranges[0]) ? '' : $ellipses[0]) . implode($ellipses[1], $out) . (($max_end < strlen($text) - 1) ? $ellipses[2] : '');
-  $text = SafeMarkup::checkPlain($text);
+  $text = Html::escape($text);
 
   // Highlight keywords. Must be done at once to prevent conflicts ('strong'
   // and '<strong>').
diff --git a/core/modules/search/src/Tests/SearchKeywordsConditionsTest.php b/core/modules/search/src/Tests/SearchKeywordsConditionsTest.php
index 7789f7a..8605d1f 100644
--- a/core/modules/search/src/Tests/SearchKeywordsConditionsTest.php
+++ b/core/modules/search/src/Tests/SearchKeywordsConditionsTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\search\Tests;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 
 /**
  * Verify the search without keywords set and extra conditions.
@@ -61,6 +61,6 @@ function testSearchKeywordsConditions() {
     $keys = 'moving drop ' . $this->randomMachineName();
     $this->drupalGet("search/dummy_path", array('query' => array('keys' => 'bike', 'search_conditions' => $keys)));
     $this->assertText("Dummy search snippet to display.");
-    $this->assertRaw(SafeMarkup::checkPlain(print_r(array('keys' => 'bike', 'search_conditions' => $keys), TRUE)));
+    $this->assertRaw(Html::escape(print_r(array('keys' => 'bike', 'search_conditions' => $keys), TRUE)));
   }
 }
diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php
index 9eda1c5..c601943 100644
--- a/core/modules/simpletest/src/AssertContentTrait.php
+++ b/core/modules/simpletest/src/AssertContentTrait.php
@@ -847,8 +847,8 @@ protected function assertThemeOutput($callback, array $variables = array(), $exp
       return \Drupal::theme()->render($callback, $variables);
     });
     $this->verbose(
-      '<hr />' . 'Result:' . '<pre>' . SafeMarkup::checkPlain(var_export($output, TRUE)) . '</pre>'
-      . '<hr />' . 'Expected:' . '<pre>' . SafeMarkup::checkPlain(var_export($expected, TRUE)) . '</pre>'
+      '<hr />' . 'Result:' . '<pre>' . Html::escape(var_export($output, TRUE)) . '</pre>'
+      . '<hr />' . 'Expected:' . '<pre>' . Html::escape(var_export($expected, TRUE)) . '</pre>'
       . '<hr />' . $output
     );
     if (!$message) {
diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php
index 2c8c862..e536ec3 100644
--- a/core/modules/simpletest/src/KernelTestBase.php
+++ b/core/modules/simpletest/src/KernelTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\simpletest;
 
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Variable;
 use Drupal\Core\Database\Database;
@@ -574,7 +575,7 @@ protected function render(array &$elements) {
     $content = $this->container->get('renderer')->renderRoot($elements);
     drupal_process_attached($elements);
     $this->setRawContent($content);
-    $this->verbose('<pre style="white-space: pre-wrap">' . SafeMarkup::checkPlain($content));
+    $this->verbose('<pre style="white-space: pre-wrap">' . Html::escape($content));
     return $content;
   }
 
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 409d0a0..b5e05ee 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -1534,7 +1534,7 @@ protected function drupalGet($path, array $options = array(), array $headers = a
     $verbose = 'GET request to: ' . $path .
                '<hr />Ending URL: ' . $this->getUrl();
     if ($this->dumpHeaders) {
-      $verbose .= '<hr />Headers: <pre>' . SafeMarkup::checkPlain(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
+      $verbose .= '<hr />Headers: <pre>' . Html::escape(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
     }
     $verbose .= '<hr />' . $out;
 
@@ -1758,7 +1758,7 @@ protected function drupalPostForm($path, $edit, $submit, array $options = array(
           $verbose = 'POST request to: ' . $path;
           $verbose .= '<hr />Ending URL: ' . $this->getUrl();
           if ($this->dumpHeaders) {
-            $verbose .= '<hr />Headers: <pre>' . SafeMarkup::checkPlain(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
+            $verbose .= '<hr />Headers: <pre>' . Html::escape(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
           }
           $verbose .= '<hr />Fields: ' . highlight_string('<?php ' . var_export($post_array, TRUE), TRUE);
           $verbose .= '<hr />' . $out;
@@ -2221,7 +2221,7 @@ protected function drupalHead($path, array $options = array(), array $headers =
     if ($this->dumpHeaders) {
       $this->verbose('GET request to: ' . $path .
                      '<hr />Ending URL: ' . $this->getUrl() .
-                     '<hr />Headers: <pre>' . SafeMarkup::checkPlain(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>');
+                     '<hr />Headers: <pre>' . Html::escape(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>');
     }
 
     return $out;
diff --git a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php
index eed2ba9..b71b9c1 100644
--- a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php
+++ b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\system\Tests\Common;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Url;
 use Drupal\simpletest\KernelTestBase;
 
@@ -46,12 +46,12 @@ protected function assertElements(array $elements, $expected_html, $message) {
     $actual_html = (string) \Drupal::service('renderer')->renderRoot($elements);
 
     $out = '<table><tr>';
-    $out .= '<td valign="top"><pre>' . SafeMarkup::checkPlain($expected_html) . '</pre></td>';
-    $out .= '<td valign="top"><pre>' . SafeMarkup::checkPlain($actual_html) . '</pre></td>';
+    $out .= '<td valign="top"><pre>' . Html::escape($expected_html) . '</pre></td>';
+    $out .= '<td valign="top"><pre>' . Html::escape($actual_html) . '</pre></td>';
     $out .= '</tr></table>';
     $this->verbose($out);
 
-    $this->assertIdentical($actual_html, $expected_html, SafeMarkup::checkPlain($message));
+    $this->assertIdentical($actual_html, $expected_html, Html::escape($message));
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Common/TableSortExtenderUnitTest.php b/core/modules/system/src/Tests/Common/TableSortExtenderUnitTest.php
index 7073c28..a836da6 100644
--- a/core/modules/system/src/Tests/Common/TableSortExtenderUnitTest.php
+++ b/core/modules/system/src/Tests/Common/TableSortExtenderUnitTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\system\Tests\Common;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\simpletest\KernelTestBase;
 use Symfony\Component\HttpFoundation\Request;
 
@@ -38,7 +38,7 @@ function testTableSortInit() {
     $request->query->replace(array());
     \Drupal::getContainer()->get('request_stack')->push($request);
     $ts = tablesort_init($headers);
-    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => SafeMarkup::checkPlain(var_export($ts, TRUE)))));
+    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Simple table headers sorted correctly.');
 
     // Test with simple table headers plus $_GET parameters that should _not_
@@ -51,7 +51,7 @@ function testTableSortInit() {
     ));
     \Drupal::getContainer()->get('request_stack')->push($request);
     $ts = tablesort_init($headers);
-    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => SafeMarkup::checkPlain(var_export($ts, TRUE)))));
+    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Simple table headers plus non-overriding $_GET parameters sorted correctly.');
 
     // Test with simple table headers plus $_GET parameters that _should_
@@ -67,7 +67,7 @@ function testTableSortInit() {
     $expected_ts['sort'] = 'desc';
     $expected_ts['query'] = array('alpha' => 'beta');
     $ts = tablesort_init($headers);
-    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => SafeMarkup::checkPlain(var_export($ts, TRUE)))));
+    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Simple table headers plus $_GET parameters sorted correctly.');
 
     // Test complex table headers.
@@ -99,7 +99,7 @@ function testTableSortInit() {
       'sort' => 'desc',
       'query' => array(),
     );
-    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => SafeMarkup::checkPlain(var_export($ts, TRUE)))));
+    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Complex table headers sorted correctly.');
 
     // Test complex table headers plus $_GET parameters that should _not_
@@ -118,7 +118,7 @@ function testTableSortInit() {
       'sort' => 'asc',
       'query' => array(),
     );
-    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => SafeMarkup::checkPlain(var_export($ts, TRUE)))));
+    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Complex table headers plus non-overriding $_GET parameters sorted correctly.');
 
     // Test complex table headers plus $_GET parameters that _should_
@@ -139,7 +139,7 @@ function testTableSortInit() {
       'query' => array('alpha' => 'beta'),
     );
     $ts = tablesort_init($headers);
-    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => SafeMarkup::checkPlain(var_export($ts, TRUE)))));
+    $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Complex table headers plus $_GET parameters sorted correctly.');
   }
 }
diff --git a/core/modules/system/src/Tests/Entity/EntityAutocompleteTest.php b/core/modules/system/src/Tests/Entity/EntityAutocompleteTest.php
index d1425c3..4db0e20 100644
--- a/core/modules/system/src/Tests/Entity/EntityAutocompleteTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityAutocompleteTest.php
@@ -9,7 +9,7 @@
 
 use Drupal\Component\Serialization\Json;
 use Drupal\Component\Utility\Crypt;
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Tags;
 use Drupal\Core\Site\Settings;
 use Drupal\system\Controller\EntityAutocompleteController;
@@ -65,8 +65,8 @@ function testEntityReferenceAutocompletion() {
     // We should get both entities in a JSON encoded string.
     $input = '10/';
     $data = $this->getAutocompleteResult($input);
-    $this->assertIdentical($data[0]['label'], SafeMarkup::checkPlain($entity_1->name->value), 'Autocomplete returned the first matching entity');
-    $this->assertIdentical($data[1]['label'], SafeMarkup::checkPlain($entity_2->name->value), 'Autocomplete returned the second matching entity');
+    $this->assertIdentical($data[0]['label'], Html::escape($entity_1->name->value), 'Autocomplete returned the first matching entity');
+    $this->assertIdentical($data[1]['label'], Html::escape($entity_2->name->value), 'Autocomplete returned the second matching entity');
 
     // Try to autocomplete a entity label that matches the first entity.
     // We should only get the first entity in a JSON encoded string.
@@ -74,7 +74,7 @@ function testEntityReferenceAutocompletion() {
     $data = $this->getAutocompleteResult($input);
     $target = array(
       'value' => $entity_1->name->value . ' (1)',
-      'label' => SafeMarkup::checkPlain($entity_1->name->value),
+      'label' => Html::escape($entity_1->name->value),
     );
     $this->assertIdentical(reset($data), $target, 'Autocomplete returns only the expected matching entity.');
 
@@ -82,7 +82,7 @@ function testEntityReferenceAutocompletion() {
     // the first entity  is already typed in the autocomplete (tags) widget.
     $input = $entity_1->name->value . ' (1), 10/17';
     $data = $this->getAutocompleteResult($input);
-    $this->assertIdentical($data[0]['label'], SafeMarkup::checkPlain($entity_2->name->value), 'Autocomplete returned the second matching entity');
+    $this->assertIdentical($data[0]['label'], Html::escape($entity_2->name->value), 'Autocomplete returned the second matching entity');
 
     // Try to autocomplete a entity label with both a comma and a slash.
     $input = '"label with, and / t';
@@ -92,7 +92,7 @@ function testEntityReferenceAutocompletion() {
     $n = Tags::encode($n);
     $target = array(
       'value' => $n,
-      'label' => SafeMarkup::checkPlain($entity_3->name->value),
+      'label' => Html::escape($entity_3->name->value),
     );
     $this->assertIdentical(reset($data), $target, 'Autocomplete returns an entity label containing a comma and a slash.');
   }
diff --git a/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
index 45e0e92..274df65 100644
--- a/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
@@ -8,7 +8,7 @@
 namespace Drupal\system\Tests\Entity\EntityReferenceSelection;
 
 use Drupal\comment\Tests\CommentTestTrait;
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\comment\CommentInterface;
 use Drupal\simpletest\WebTestBase;
@@ -110,7 +110,7 @@ public function testNodeHandler() {
       $node = entity_create('node', $values);
       $node->save();
       $nodes[$key] = $node;
-      $node_labels[$key] = SafeMarkup::checkPlain($node->label());
+      $node_labels[$key] = Html::escape($node->label());
     }
 
     // Test as a non-admin.
@@ -241,7 +241,7 @@ public function testUserHandler() {
         $account = $values;
       }
       $users[$key] = $account;
-      $user_labels[$key] = SafeMarkup::checkPlain($account->getUsername());
+      $user_labels[$key] = Html::escape($account->getUsername());
     }
 
     // Test as a non-admin.
@@ -416,7 +416,7 @@ public function testCommentHandler() {
       $comment = entity_create('comment', $values);
       $comment->save();
       $comments[$key] = $comment;
-      $comment_labels[$key] = SafeMarkup::checkPlain($comment->label());
+      $comment_labels[$key] = Html::escape($comment->label());
     }
 
     // Test as a non-admin.
diff --git a/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php
index 3fae878..98be261 100644
--- a/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\system\Tests\Entity\EntityReferenceSelection;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\node\Entity\Node;
 use Drupal\node\Entity\NodeType;
 use Drupal\system\Tests\Entity\EntityUnitTestBase;
@@ -93,7 +93,7 @@ public function testSort() {
       $node = Node::create($values);
       $node->save();
       $nodes[$key] = $node;
-      $node_labels[$key] = SafeMarkup::checkPlain($node->label());
+      $node_labels[$key] = Html::escape($node->label());
     }
 
     $selection_options = array(
diff --git a/core/modules/system/src/Tests/Form/FormTest.php b/core/modules/system/src/Tests/Form/FormTest.php
index 67508a2..4585ad1 100644
--- a/core/modules/system/src/Tests/Form/FormTest.php
+++ b/core/modules/system/src/Tests/Form/FormTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\system\Tests\Form;
 
 use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Form\FormState;
 use Drupal\Core\Render\Element;
@@ -616,7 +617,7 @@ function testDisabledMarkup() {
       $path = strtr($path, array('!type' => $type));
       // Verify that the element exists.
       $element = $this->xpath($path, array(
-        ':name' => SafeMarkup::checkPlain($name),
+        ':name' => Html::escape($name),
         ':div-class' => $class,
         ':value' => isset($item['#value']) ? $item['#value'] : '',
       ));
diff --git a/core/modules/system/src/Tests/Mail/HtmlToTextTest.php b/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
index fe6f7c0..a78406d 100644
--- a/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
+++ b/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\system\Tests\Mail;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Mail\MailFormatHelper;
 use Drupal\Core\Site\Settings;
@@ -34,7 +34,7 @@ protected function stringToHtml($text) {
       str_replace(
         array("\n", ' '),
         array('\n', '&nbsp;'),
-        SafeMarkup::checkPlain($text)
+        Html::escape($text)
       ) . '"';
   }
 
@@ -57,7 +57,7 @@ protected function assertHtmlToText($html, $text, $message, $allowed_tags = NULL
     $tested_tags = implode(', ', array_unique($matches[1]));
     $message .= ' (' . $tested_tags . ')';
     $result = MailFormatHelper::htmlToText($html, $allowed_tags);
-    $pass = $this->assertEqual($result, $text, SafeMarkup::checkPlain($message));
+    $pass = $this->assertEqual($result, $text, Html::escape($message));
     $verbose = 'html = <pre>' . $this->stringToHtml($html)
       . '</pre><br />' . 'result = <pre>' . $this->stringToHtml($result)
       . '</pre><br />' . 'expected = <pre>' . $this->stringToHtml($text)
diff --git a/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php b/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php
index e2f4ca7..60adadf 100644
--- a/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php
+++ b/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\system\Tests\Menu;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Url;
 
 /**
@@ -83,7 +83,7 @@ protected function assertBreadcrumbParts($trail) {
           $url = $path;
         }
         $part = array_shift($parts);
-        $pass = ($pass && $part['href'] === $url && $part['text'] === SafeMarkup::checkPlain($title));
+        $pass = ($pass && $part['href'] === $url && $part['text'] === Html::escape($title));
       }
     }
     // No parts must be left, or an expected "Home" will always pass.
diff --git a/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php b/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php
index 1b22d5c..ee3b6eb 100644
--- a/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php
+++ b/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\system\Tests\Routing;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\simpletest\KernelTestBase;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
@@ -116,7 +116,7 @@ public function testBacktraceEscaping() {
 
     // Test both that the backtrace is properly escaped, and that the unescaped
     // string is not output at all.
-    $this->assertTrue(strpos($response->getContent(), SafeMarkup::checkPlain('<script>alert(\'xss\')</script>')) !== FALSE);
+    $this->assertTrue(strpos($response->getContent(), Html::escape('<script>alert(\'xss\')</script>')) !== FALSE);
     $this->assertTrue(strpos($response->getContent(), '<script>alert(\'xss\')</script>') === FALSE);
   }
 
@@ -140,7 +140,7 @@ public function testExceptionEscaping() {
     // Test message is properly escaped, and that the unescaped string is not
     // output at all.
     $this->setRawContent($response->getContent());
-    $this->assertRaw(SafeMarkup::checkPlain('Escaped content: <p> <br> <h3>'));
+    $this->assertRaw(Html::escape('Escaped content: <p> <br> <h3>'));
     $this->assertNoRaw('<p> <br> <h3>');
   }
 
diff --git a/core/modules/system/src/Tests/System/PageTitleTest.php b/core/modules/system/src/Tests/System/PageTitleTest.php
index 6d56a6f..369b554 100644
--- a/core/modules/system/src/Tests/System/PageTitleTest.php
+++ b/core/modules/system/src/Tests/System/PageTitleTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\system\Tests\System;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Xss;
 use Drupal\simpletest\WebTestBase;
 
@@ -55,9 +55,9 @@ function testTitleTags() {
 
     $node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
     $this->assertNotNull($node, 'Node created and found in database');
-    $this->assertText(SafeMarkup::checkPlain($edit['title[0][value]']), 'Check to make sure tags in the node title are converted.');
+    $this->assertText(Html::escape($edit['title[0][value]']), 'Check to make sure tags in the node title are converted.');
     $this->drupalGet("node/" . $node->id());
-    $this->assertText(SafeMarkup::checkPlain($edit['title[0][value]']), 'Check to make sure tags in the node title are converted.');
+    $this->assertText(Html::escape($edit['title[0][value]']), 'Check to make sure tags in the node title are converted.');
   }
 
   /**
@@ -66,7 +66,7 @@ function testTitleTags() {
   function testTitleXSS() {
     // Set some title with JavaScript and HTML chars to escape.
     $title = '</title><script type="text/javascript">alert("Title XSS!");</script> & < > " \' ';
-    $title_filtered = SafeMarkup::checkPlain($title);
+    $title_filtered = Html::escape($title);
 
     $slogan = '<script type="text/javascript">alert("Slogan XSS!");</script>';
     $slogan_filtered = Xss::filterAdmin($slogan);
@@ -143,19 +143,19 @@ public function testRoutingTitle() {
     // controller does not escape them.
     $this->drupalGet('test-page-cached-controller');
     $this->assertTitle('Cached title | Drupal');
-    $this->assertRaw(SafeMarkup::checkPlain('<span>Cached title</span>') . '</h1>');
+    $this->assertRaw(Html::escape('<span>Cached title</span>') . '</h1>');
     $this->drupalGet('test-page-cached-controller');
     $this->assertTitle('Cached title | Drupal');
-    $this->assertRaw(SafeMarkup::checkPlain('<span>Cached title</span>') . '</h1>');
+    $this->assertRaw(Html::escape('<span>Cached title</span>') . '</h1>');
 
     // Ensure that titles are cacheable and are escaped normally if the
-    // controller escapes them use SafeMarkup::checkPlain().
+    // controller escapes them use Html::escape().
     $this->drupalGet('test-page-cached-controller-safe');
     $this->assertTitle('<span>Cached title</span> | Drupal');
-    $this->assertRaw(SafeMarkup::checkPlain('<span>Cached title</span>') . '</h1>');
+    $this->assertRaw(Html::escape('<span>Cached title</span>') . '</h1>');
     $this->drupalGet('test-page-cached-controller-safe');
     $this->assertTitle('<span>Cached title</span> | Drupal');
-    $this->assertRaw(SafeMarkup::checkPlain('<span>Cached title</span>') . '</h1>');
+    $this->assertRaw(Html::escape('<span>Cached title</span>') . '</h1>');
   }
 
 }
diff --git a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php
index b8f31e7..33f867a 100644
--- a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php
+++ b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\system\Tests\System;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Render\BubbleableMetadata;
 
@@ -70,7 +70,7 @@ public function testClear() {
     $source .= '[bogus:token]';
 
     // Replace with with the clear parameter, only the valid token should remain.
-    $target = SafeMarkup::checkPlain($this->config('system.site')->get('name'));
+    $target = Html::escape($this->config('system.site')->get('name'));
     $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId(), 'clear' => TRUE));
     $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.');
 
@@ -105,7 +105,7 @@ public function testSystemSiteTokenReplacement() {
 
     // Generate and test sanitized tokens.
     $tests = array();
-    $tests['[site:name]'] = SafeMarkup::checkPlain($config->get('name'));
+    $tests['[site:name]'] = Html::escape($config->get('name'));
     $tests['[site:slogan]'] = $safe_slogan;
     $tests['[site:mail]'] = $config->get('mail');
     $tests['[site:url]'] = \Drupal::url('<front>', [], $url_options);
diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php
index 0ed135d..44f4507 100644
--- a/core/modules/system/src/Tests/Theme/FunctionsTest.php
+++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\system\Tests\Theme;
 
 use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Session\UserSession;
 use Drupal\Core\Url;
@@ -218,13 +219,13 @@ function testLinks() {
 
     $expected_links = '';
     $expected_links .= '<ul id="somelinks">';
-    $expected_links .= '<li class="a-link"><a href="' . Url::fromUri('base:a/link')->toString() . '">' . SafeMarkup::checkPlain('A <link>') . '</a></li>';
-    $expected_links .= '<li class="plain-text">' . SafeMarkup::checkPlain('Plain "text"') . '</li>';
-    $expected_links .= '<li class="html-text"><span class="unescaped">' . SafeMarkup::checkPlain('potentially unsafe text that <should> be escaped') . '</span></li>';
-    $expected_links .= '<li class="front-page"><a href="' . Url::fromRoute('<front>')->toString() . '">' . SafeMarkup::checkPlain('Front page') . '</a></li>';
-    $expected_links .= '<li class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . SafeMarkup::checkPlain('Test route') . '</a></li>';
+    $expected_links .= '<li class="a-link"><a href="' . Url::fromUri('base:a/link')->toString() . '">' . Html::escape('A <link>') . '</a></li>';
+    $expected_links .= '<li class="plain-text">' . Html::escape('Plain "text"') . '</li>';
+    $expected_links .= '<li class="html-text"><span class="unescaped">' . Html::escape('potentially unsafe text that <should> be escaped') . '</span></li>';
+    $expected_links .= '<li class="front-page"><a href="' . Url::fromRoute('<front>')->toString() . '">' . Html::escape('Front page') . '</a></li>';
+    $expected_links .= '<li class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . Html::escape('Test route') . '</a></li>';
     $query = array('key' => 'value');
-    $expected_links .= '<li class="query-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '">' . SafeMarkup::checkPlain('Query test route') . '</a></li>';
+    $expected_links .= '<li class="query-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '">' . Html::escape('Query test route') . '</a></li>';
     $expected_links .= '</ul>';
 
     // Verify that passing a string as heading works.
@@ -258,13 +259,13 @@ function testLinks() {
     );
     $expected_links = '';
     $expected_links .= '<ul id="somelinks">';
-    $expected_links .= '<li class="a-link"><a href="' . Url::fromUri('base:a/link')->toString() . '">' . SafeMarkup::checkPlain('A <link>') . '</a></li>';
-    $expected_links .= '<li class="plain-text"><span class="a/class">' . SafeMarkup::checkPlain('Plain "text"') . '</span></li>';
-    $expected_links .= '<li class="html-text"><span class="unescaped">' . SafeMarkup::checkPlain('potentially unsafe text that <should> be escaped') . '</span></li>';
-    $expected_links .= '<li class="front-page"><a href="' . Url::fromRoute('<front>')->toString() . '">' . SafeMarkup::checkPlain('Front page') . '</a></li>';
-    $expected_links .= '<li class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . SafeMarkup::checkPlain('Test route') . '</a></li>';
+    $expected_links .= '<li class="a-link"><a href="' . Url::fromUri('base:a/link')->toString() . '">' . Html::escape('A <link>') . '</a></li>';
+    $expected_links .= '<li class="plain-text"><span class="a/class">' . Html::escape('Plain "text"') . '</span></li>';
+    $expected_links .= '<li class="html-text"><span class="unescaped">' . Html::escape('potentially unsafe text that <should> be escaped') . '</span></li>';
+    $expected_links .= '<li class="front-page"><a href="' . Url::fromRoute('<front>')->toString() . '">' . Html::escape('Front page') . '</a></li>';
+    $expected_links .= '<li class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . Html::escape('Test route') . '</a></li>';
     $query = array('key' => 'value');
-    $expected_links .= '<li class="query-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '">' . SafeMarkup::checkPlain('Query test route') . '</a></li>';
+    $expected_links .= '<li class="query-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '">' . Html::escape('Query test route') . '</a></li>';
     $expected_links .= '</ul>';
     $expected = $expected_heading . $expected_links;
     $this->assertThemeOutput('links', $variables, $expected);
@@ -274,14 +275,14 @@ function testLinks() {
     $variables['set_active_class'] = TRUE;
     $expected_links = '';
     $expected_links .= '<ul id="somelinks">';
-    $expected_links .= '<li class="a-link"><a href="' . Url::fromUri('base:a/link')->toString() . '">' . SafeMarkup::checkPlain('A <link>') . '</a></li>';
-    $expected_links .= '<li class="plain-text"><span class="a/class">' . SafeMarkup::checkPlain('Plain "text"') . '</span></li>';
-    $expected_links .= '<li class="html-text"><span class="unescaped">' . SafeMarkup::checkPlain('potentially unsafe text that <should> be escaped') . '</span></li>';
-    $expected_links .= '<li data-drupal-link-system-path="&lt;front&gt;" class="front-page"><a href="' . Url::fromRoute('<front>')->toString() . '" data-drupal-link-system-path="&lt;front&gt;">' . SafeMarkup::checkPlain('Front page') . '</a></li>';
-    $expected_links .= '<li data-drupal-link-system-path="router_test/test1" class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '" data-drupal-link-system-path="router_test/test1">' . SafeMarkup::checkPlain('Test route') . '</a></li>';
+    $expected_links .= '<li class="a-link"><a href="' . Url::fromUri('base:a/link')->toString() . '">' . Html::escape('A <link>') . '</a></li>';
+    $expected_links .= '<li class="plain-text"><span class="a/class">' . Html::escape('Plain "text"') . '</span></li>';
+    $expected_links .= '<li class="html-text"><span class="unescaped">' . Html::escape('potentially unsafe text that <should> be escaped') . '</span></li>';
+    $expected_links .= '<li data-drupal-link-system-path="&lt;front&gt;" class="front-page"><a href="' . Url::fromRoute('<front>')->toString() . '" data-drupal-link-system-path="&lt;front&gt;">' . Html::escape('Front page') . '</a></li>';
+    $expected_links .= '<li data-drupal-link-system-path="router_test/test1" class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '" data-drupal-link-system-path="router_test/test1">' . Html::escape('Test route') . '</a></li>';
     $query = array('key' => 'value');
-    $encoded_query = SafeMarkup::checkPlain(Json::encode($query));
-    $expected_links .= '<li data-drupal-link-query="'.$encoded_query.'" data-drupal-link-system-path="router_test/test1" class="query-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '" data-drupal-link-query="'.$encoded_query.'" data-drupal-link-system-path="router_test/test1">' . SafeMarkup::checkPlain('Query test route') . '</a></li>';
+    $encoded_query = Html::escape(Json::encode($query));
+    $expected_links .= '<li data-drupal-link-query="'.$encoded_query.'" data-drupal-link-system-path="router_test/test1" class="query-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '" data-drupal-link-query="'.$encoded_query.'" data-drupal-link-system-path="router_test/test1">' . Html::escape('Query test route') . '</a></li>';
     $expected_links .= '</ul>';
     $expected = $expected_heading . $expected_links;
     $this->assertThemeOutput('links', $variables, $expected);
diff --git a/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php b/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php
index e6e5988..1bab9bf 100644
--- a/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php
+++ b/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\system\Tests\Theme;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Site\Settings;
 use Drupal\simpletest\KernelTestBase;
 
@@ -44,7 +44,7 @@ public function testInlineTemplate() {
       '#template' => 'test-with-context <label>{{ unsafe_content }}</label>',
       '#context' => array('unsafe_content' => $unsafe_string),
     );
-    $this->assertEqual($renderer->renderRoot($element), 'test-with-context <label>' . SafeMarkup::checkPlain($unsafe_string) . '</label>');
+    $this->assertEqual($renderer->renderRoot($element), 'test-with-context <label>' . Html::escape($unsafe_string) . '</label>');
 
     // Enable twig_auto_reload and twig_debug.
     $settings = Settings::getAll();
diff --git a/core/modules/system/system.tokens.inc b/core/modules/system/system.tokens.inc
index 4c0e107..31b8030 100644
--- a/core/modules/system/system.tokens.inc
+++ b/core/modules/system/system.tokens.inc
@@ -7,7 +7,7 @@
  * This file handles tokens for the global 'site' and 'date' tokens.
  */
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Datetime\Entity\DateFormat;
 use Drupal\Core\Render\BubbleableMetadata;
@@ -111,7 +111,7 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
           $config = \Drupal::config('system.site');
           $bubbleable_metadata->addCacheableDependency($config);
           $site_name = $config->get('name');
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($site_name) : $site_name;
+          $replacements[$original] = $sanitize ? Html::escape($site_name) : $site_name;
           break;
 
         case 'slogan':
@@ -188,7 +188,7 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
           break;
 
         case 'raw':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($date) : $date;
+          $replacements[$original] = $sanitize ? Html::escape($date) : $date;
           break;
       }
     }
diff --git a/core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php b/core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php
index 6b43aa8..cbe4b14 100644
--- a/core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php
+++ b/core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\common_test\Controller;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Url;
 use Symfony\Component\HttpFoundation\Response;
 
@@ -89,7 +89,7 @@ public function jsAndCssQuerystring() {
    */
   public function destination() {
     $destination = \Drupal::destination()->getAsArray();
-    $output = "The destination: " . SafeMarkup::checkPlain($destination['destination']);
+    $output = "The destination: " . Html::escape($destination['destination']);
     return new Response($output);
   }
 
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php
index 7f62557..3a6d1c5 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\form_test\Form;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
 
@@ -139,7 +139,7 @@ public function continueSubmitForm(array &$form, FormStateInterface $form_state)
    * {@inheritdoc}
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
-    drupal_set_message("Title: " . SafeMarkup::checkPlain($form_state->getValue('title')));
+    drupal_set_message("Title: " . Html::escape($form_state->getValue('title')));
     drupal_set_message("Form constructions: " . $_SESSION['constructions']);
     if ($form_state->has(['thing', 'changed'])) {
       drupal_set_message("The thing has been changed.");
diff --git a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php
index ff7c8ef..4fcb0f1 100644
--- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php
+++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\taxonomy\Tests;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\Render\BubbleableMetadata;
@@ -86,13 +86,13 @@ function testTaxonomyTokenReplacement() {
     // Generate and test sanitized tokens for term1.
     $tests = array();
     $tests['[term:tid]'] = $term1->id();
-    $tests['[term:name]'] = SafeMarkup::checkPlain($term1->getName());
+    $tests['[term:name]'] = Html::escape($term1->getName());
     $tests['[term:description]'] = $term1->description->processed;
     $tests['[term:url]'] = $term1->url('canonical', array('absolute' => TRUE));
     $tests['[term:node-count]'] = 0;
     $tests['[term:parent:name]'] = '[term:parent:name]';
-    $tests['[term:vocabulary:name]'] = SafeMarkup::checkPlain($this->vocabulary->label());
-    $tests['[term:vocabulary]'] = SafeMarkup::checkPlain($this->vocabulary->label());
+    $tests['[term:vocabulary:name]'] = Html::escape($this->vocabulary->label());
+    $tests['[term:vocabulary]'] = Html::escape($this->vocabulary->label());
 
     $base_bubbleable_metadata = BubbleableMetadata::createFromObject($term1);
 
@@ -117,14 +117,14 @@ function testTaxonomyTokenReplacement() {
     // Generate and test sanitized tokens for term2.
     $tests = array();
     $tests['[term:tid]'] = $term2->id();
-    $tests['[term:name]'] = SafeMarkup::checkPlain($term2->getName());
+    $tests['[term:name]'] = Html::escape($term2->getName());
     $tests['[term:description]'] = $term2->description->processed;
     $tests['[term:url]'] = $term2->url('canonical', array('absolute' => TRUE));
     $tests['[term:node-count]'] = 1;
-    $tests['[term:parent:name]'] = SafeMarkup::checkPlain($term1->getName());
+    $tests['[term:parent:name]'] = Html::escape($term1->getName());
     $tests['[term:parent:url]'] = $term1->url('canonical', array('absolute' => TRUE));
     $tests['[term:parent:parent:name]'] = '[term:parent:parent:name]';
-    $tests['[term:vocabulary:name]'] = SafeMarkup::checkPlain($this->vocabulary->label());
+    $tests['[term:vocabulary:name]'] = Html::escape($this->vocabulary->label());
 
     // Test to make sure that we generated something for each token.
     $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
@@ -148,7 +148,7 @@ function testTaxonomyTokenReplacement() {
     // Generate and test sanitized tokens.
     $tests = array();
     $tests['[vocabulary:vid]'] = $this->vocabulary->id();
-    $tests['[vocabulary:name]'] = SafeMarkup::checkPlain($this->vocabulary->label());
+    $tests['[vocabulary:name]'] = Html::escape($this->vocabulary->label());
     $tests['[vocabulary:description]'] = Xss::filter($this->vocabulary->getDescription());
     $tests['[vocabulary:node-count]'] = 1;
     $tests['[vocabulary:term-count]'] = 2;
diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc
index 824116c..daf690b 100644
--- a/core/modules/taxonomy/taxonomy.tokens.inc
+++ b/core/modules/taxonomy/taxonomy.tokens.inc
@@ -5,7 +5,7 @@
  * Builds placeholder replacement tokens for taxonomy terms and vocabularies.
  */
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Render\BubbleableMetadata;
 use Drupal\taxonomy\Entity\Vocabulary;
@@ -109,7 +109,7 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
           break;
 
         case 'name':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($term->getName()) : $term->getName();
+          $replacements[$original] = $sanitize ? Html::escape($term->getName()) : $term->getName();
           break;
 
         case 'description':
@@ -131,14 +131,14 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
         case 'vocabulary':
           $vocabulary = Vocabulary::load($term->bundle());
           $bubbleable_metadata->addCacheableDependency($vocabulary);
-          $replacements[$original] = SafeMarkup::checkPlain($vocabulary->label());
+          $replacements[$original] = Html::escape($vocabulary->label());
           break;
 
         case 'parent':
           if ($parents = $taxonomy_storage->loadParents($term->id())) {
             $parent = array_pop($parents);
             $bubbleable_metadata->addCacheableDependency($parent);
-            $replacements[$original] = SafeMarkup::checkPlain($parent->getName());
+            $replacements[$original] = Html::escape($parent->getName());
           }
           break;
       }
@@ -165,7 +165,7 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
           break;
 
         case 'name':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($vocabulary->label()) : $vocabulary->label();
+          $replacements[$original] = $sanitize ? Html::escape($vocabulary->label()) : $vocabulary->label();
           break;
 
         case 'description':
diff --git a/core/modules/tour/src/Plugin/tour/tip/TipPluginText.php b/core/modules/tour/src/Plugin/tour/tip/TipPluginText.php
index c457beb..bedb4bd 100644
--- a/core/modules/tour/src/Plugin/tour/tip/TipPluginText.php
+++ b/core/modules/tour/src/Plugin/tour/tip/TipPluginText.php
@@ -8,7 +8,6 @@
 namespace Drupal\tour\Plugin\tour\tip;
 
 use Drupal\Component\Utility\Html;
-use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Drupal\Core\Utility\Token;
@@ -121,7 +120,7 @@ public function getAttributes() {
    * {@inheritdoc}
    */
   public function getOutput() {
-    $output = '<h2 class="tour-tip-label" id="tour-tip-' . $this->getAriaId() . '-label">' . SafeMarkup::checkPlain($this->getLabel()) . '</h2>';
+    $output = '<h2 class="tour-tip-label" id="tour-tip-' . $this->getAriaId() . '-label">' . Html::escape($this->getLabel()) . '</h2>';
     $output .= '<p class="tour-tip-body" id="tour-tip-' . $this->getAriaId() . '-contents">' . Xss::filterAdmin($this->token->replace($this->getBody())) . '</p>';
     return array('#markup' => $output);
   }
diff --git a/core/modules/tour/tests/tour_test/src/Plugin/tour/tip/TipPluginImage.php b/core/modules/tour/tests/tour_test/src/Plugin/tour/tip/TipPluginImage.php
index 5c683b9..503a909 100644
--- a/core/modules/tour/tests/tour_test/src/Plugin/tour/tip/TipPluginImage.php
+++ b/core/modules/tour/tests/tour_test/src/Plugin/tour/tip/TipPluginImage.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\tour_test\Plugin\tour\tip;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\tour\TipPluginBase;
 
 /**
@@ -40,7 +40,7 @@ class TipPluginImage extends TipPluginBase {
    * {@inheritdoc}
    */
   public function getOutput() {
-    $prefix = '<h2 class="tour-tip-label" id="tour-tip-' . $this->get('ariaId') . '-label">' . SafeMarkup::checkPlain($this->get('label')) . '</h2>';
+    $prefix = '<h2 class="tour-tip-label" id="tour-tip-' . $this->get('ariaId') . '-label">' . Html::escape($this->get('label')) . '</h2>';
     $prefix .= '<p class="tour-tip-image" id="tour-tip-' . $this->get('ariaId') . '-contents">';
     return [
       '#prefix' => $prefix,
diff --git a/core/modules/user/src/Tests/UserTokenReplaceTest.php b/core/modules/user/src/Tests/UserTokenReplaceTest.php
index 508275c..661ce2f 100644
--- a/core/modules/user/src/Tests/UserTokenReplaceTest.php
+++ b/core/modules/user/src/Tests/UserTokenReplaceTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\user\Tests;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Render\BubbleableMetadata;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\simpletest\WebTestBase;
@@ -57,15 +57,15 @@ function testUserTokenReplacement() {
     // Generate and test sanitized tokens.
     $tests = array();
     $tests['[user:uid]'] = $account->id();
-    $tests['[user:name]'] = SafeMarkup::checkPlain(user_format_name($account));
-    $tests['[user:mail]'] = SafeMarkup::checkPlain($account->getEmail());
+    $tests['[user:name]'] = Html::escape(user_format_name($account));
+    $tests['[user:mail]'] = Html::escape($account->getEmail());
     $tests['[user:url]'] = $account->url('canonical', $url_options);
     $tests['[user:edit-url]'] = $account->url('edit-form', $url_options);
     $tests['[user:last-login]'] = format_date($account->getLastLoginTime(), 'medium', '', NULL, $language_interface->getId());
     $tests['[user:last-login:short]'] = format_date($account->getLastLoginTime(), 'short', '', NULL, $language_interface->getId());
     $tests['[user:created]'] = format_date($account->getCreatedTime(), 'medium', '', NULL, $language_interface->getId());
     $tests['[user:created:short]'] = format_date($account->getCreatedTime(), 'short', '', NULL, $language_interface->getId());
-    $tests['[current-user:name]'] = SafeMarkup::checkPlain(user_format_name($global_account));
+    $tests['[current-user:name]'] = Html::escape(user_format_name($global_account));
 
     $base_bubbleable_metadata = BubbleableMetadata::createFromObject($account);
     $metadata_tests = [];
@@ -101,7 +101,7 @@ function testUserTokenReplacement() {
     $anonymous_user = User::load(0);
     $tests = [];
     $tests['[user:uid]'] = t('not yet assigned');
-    $tests['[user:name]'] = SafeMarkup::checkPlain(user_format_name($anonymous_user));
+    $tests['[user:name]'] = Html::escape(user_format_name($anonymous_user));
 
     $base_bubbleable_metadata = BubbleableMetadata::createFromObject($anonymous_user);
     $metadata_tests = [];
diff --git a/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php b/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php
index 5ea1b0f..b781f07 100644
--- a/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php
+++ b/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\user\Tests\Views;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\views\Views;
 
 /**
@@ -86,7 +86,7 @@ public function testFilterPermission() {
     }
     foreach (array('system' => 'System', 'user' => 'User') as $module => $title) {
       $expected = array_map(function ($permission) {
-        return SafeMarkup::checkPlain(strip_tags($permission['title']));
+        return Html::escape(strip_tags($permission['title']));
       }, $permission_by_module[$module]);
 
       $this->assertEqual($expected, $value_options[$title], 'Ensure the all permissions are available');
diff --git a/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php b/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php
index 3a4db29..f382579 100644
--- a/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php
+++ b/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\Tests\user\Unit\Views\Argument;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Drupal\Tests\UnitTestCase;
 use Drupal\user\Entity\Role;
@@ -81,7 +81,7 @@ public function testTitleQuery() {
 
     $roles_rid_argument->value = array('test_rid_1', 'test_rid_2');
     $titles = $roles_rid_argument->title_query();
-    $this->assertEquals(array('test rid 1', SafeMarkup::checkPlain('test <strong>rid 2</strong>')), $titles);
+    $this->assertEquals(array('test rid 1', Html::escape('test <strong>rid 2</strong>')), $titles);
   }
 
 }
diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc
index 582c1cd..9cb61f6 100644
--- a/core/modules/user/user.tokens.inc
+++ b/core/modules/user/user.tokens.inc
@@ -5,7 +5,7 @@
  * Builds placeholder replacement tokens for user-related data.
  */
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Datetime\Entity\DateFormat;
 use Drupal\Core\Render\BubbleableMetadata;
 use Drupal\user\Entity\User;
@@ -97,11 +97,11 @@ function user_tokens($type, $tokens, array $data, array $options, BubbleableMeta
           if ($account->isAnonymous()) {
             $bubbleable_metadata->addCacheableDependency(\Drupal::config('user.settings'));
           }
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($name) : $name;
+          $replacements[$original] = $sanitize ? Html::escape($name) : $name;
           break;
 
         case 'mail':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($account->getEmail()) : $account->getEmail();
+          $replacements[$original] = $sanitize ? Html::escape($account->getEmail()) : $account->getEmail();
           break;
 
         case 'url':
diff --git a/core/modules/views/views.tokens.inc b/core/modules/views/views.tokens.inc
index eb766bc..33d162b 100644
--- a/core/modules/views/views.tokens.inc
+++ b/core/modules/views/views.tokens.inc
@@ -5,7 +5,7 @@
  * Token integration for the views module.
  */
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Render\BubbleableMetadata;
 
 /**
@@ -87,11 +87,11 @@ function views_tokens($type, $tokens, array $data, array $options, BubbleableMet
     foreach ($tokens as $name => $original) {
       switch ($name) {
         case 'label':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($view->storage->label()) : $view->storage->label();
+          $replacements[$original] = $sanitize ? Html::escape($view->storage->label()) : $view->storage->label();
           break;
 
         case 'description':
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($view->storage->get('description')) : $view->storage->get('description');
+          $replacements[$original] = $sanitize ? Html::escape($view->storage->get('description')) : $view->storage->get('description');
           break;
 
         case 'id':
@@ -100,7 +100,7 @@ function views_tokens($type, $tokens, array $data, array $options, BubbleableMet
 
         case 'title':
           $title = $view->getTitle();
-          $replacements[$original] = $sanitize ? SafeMarkup::checkPlain($title) : $title;
+          $replacements[$original] = $sanitize ? Html::escape($title) : $title;
           break;
 
         case 'url':
diff --git a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php
index 06bbd0a..f58484c 100644
--- a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php
+++ b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\views_ui\Form\Ajax;
 
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\ViewExecutable;
 
@@ -52,7 +52,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       return $form;
     }
     $display = $executable->displayHandlers->get($display_id);
-    $form['#title'] = SafeMarkup::checkPlain($display->display['display_title']) . ': ';
+    $form['#title'] = Html::escape($display->display['display_title']) . ': ';
     $form['#title'] .= $this->t('Rearrange @type', array('@type' => $types[$type]['ltitle']));
     $form['#section'] = $display_id . 'rearrange-item';
 
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index 376fed2..f235839 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\KernelTests;
 
+use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Config\ConfigImporter;
 use Drupal\Core\Config\StorageComparer;
@@ -844,7 +845,7 @@ protected function render(array &$elements) {
     $content = $this->container->get('renderer')->render($elements);
     drupal_process_attached($elements);
     $this->setRawContent($content);
-    $this->verbose('<pre style="white-space: pre-wrap">' . SafeMarkup::checkPlain($content));
+    $this->verbose('<pre style="white-space: pre-wrap">' . Html::escape($content));
     return $content;
   }
 
