diff --git a/core/CHANGELOG.txt b/core/CHANGELOG.txt
index 83fc766..55b19bb 100644
--- a/core/CHANGELOG.txt
+++ b/core/CHANGELOG.txt
@@ -106,7 +106,8 @@ Drupal 8.0, xxxx-xx-xx (development version)
         developers.
       * Made it possible for users to have a preferred language separate from
         their user entity language.
-      * The text formatter from t() is now available as format_string().
+      * The text formatter from t() is now available as
+        \Drupal\Component\Utility\SafeMarkup::format().
       * Added support for interface translation contexts in Drupal.t(),
         Drupal.formatPlural() as well as routing, tabs, actions, and contextual
         links.
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 26a75f6..1bed29c 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -173,7 +173,7 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) {
   if (!empty($config_directories[$type])) {
     return $config_directories[$type];
   }
-  throw new \Exception(format_string('The configuration directory type %type does not exist.', array('%type' => $type)));
+  throw new \Exception(SafeMarkup::format('The configuration directory type %type does not exist.', array('%type' => $type)));
 }
 
 /**
@@ -398,7 +398,7 @@ function _drupal_set_preferred_header_name($name = NULL) {
  * Basically, you can put variables like @name into your string, and t() will
  * substitute their sanitized values at translation time. (See the
  * Localization API pages referenced above and the documentation of
- * format_string() for details about how to define variables in your string.)
+ * SafeMarkup::format() for details about how to define variables in your string.)
  * Translators can then rearrange the string as necessary for the language
  * (e.g., in Spanish, it might be "blog de @name").
  *
@@ -407,7 +407,7 @@ function _drupal_set_preferred_header_name($name = NULL) {
  * @param $args
  *   An associative array of replacements to make after translation. Based
  *   on the first character of the key, the value is escaped and/or themed.
- *   See format_string() for details.
+ *   See \Drupal\Component\Utility\SafeMarkup::format() for details.
  * @param $options
  *   An associative array of additional options, with the following elements:
  *   - 'langcode' (defaults to the current language): The language code to
@@ -418,7 +418,7 @@ function _drupal_set_preferred_header_name($name = NULL) {
  * @return
  *   The translated string.
  *
- * @see format_string()
+ * @see \Drupal\Component\Utility\SafeMarkup::format()
  * @ingroup sanitization
  */
 function t($string, array $args = array(), array $options = array()) {
@@ -431,6 +431,9 @@ function t($string, array $args = array(), array $options = array()) {
  * @see \Drupal\Component\Utility\SafeMarkup::format()
  * @see t()
  * @ingroup sanitization
+ *
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ *   Use \Drupal\Component\Utility\SafeMarkup::format().
  */
 function format_string($string, array $args = array()) {
   return SafeMarkup::format($string, $args);
diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index fa3bc6b..043b437 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -6,6 +6,7 @@
  */
 
 use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Logger\RfcLogLevel;
 use Drupal\Core\Utility\Error;
@@ -168,7 +169,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
     if ($fatal) {
       // When called from CLI, simply output a plain text message.
       // Should not translate the string to avoid errors producing more errors.
-      print html_entity_decode(strip_tags(format_string('%type: !message in %function (line %line of %file).', $error))). "\n";
+      print html_entity_decode(strip_tags(SafeMarkup::format('%type: !message in %function (line %line of %file).', $error))). "\n";
       exit;
     }
   }
@@ -178,7 +179,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
       if (error_displayable($error)) {
         // When called from JavaScript, simply output the error message.
         // Should not translate the string to avoid errors producing more errors.
-        print format_string('%type: !message in %function (line %line of %file).', $error);
+        print SafeMarkup::format('%type: !message in %function (line %line of %file).', $error);
       }
       exit;
     }
@@ -206,7 +207,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
         }
       }
       // Should not translate the string to avoid errors producing more errors.
-      $message = format_string('%type: !message in %function (line %line of %file).', $error);
+      $message = SafeMarkup::format('%type: !message in %function (line %line of %file).', $error);
 
       // Check if verbose error reporting is on.
       $error_level = _drupal_get_error_level();
diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 251b81d..614b906 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -38,7 +38,7 @@ function template_preprocess_menu_local_task(&$variables) {
     $variables['attributes']['class'] = array('active');
 
     // Add text to indicate active tab for non-visual users.
-    $active = String::format('<span class="visually-hidden">@label</span>', array('@label' => t('(active tab)')));
+    $active = SafeMarkup::format('<span class="visually-hidden">@label</span>', array('@label' => t('(active tab)')));
     $link_text = t('@local-task-title@active', array('@local-task-title' => $link_text, '@active' => $active));
   }
   else {
diff --git a/core/includes/tablesort.inc b/core/includes/tablesort.inc
index d417975..4cc7dbd 100644
--- a/core/includes/tablesort.inc
+++ b/core/includes/tablesort.inc
@@ -1,5 +1,6 @@
 <?php
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Url;
 use Drupal\Component\Utility\UrlHelper;
@@ -60,7 +61,7 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header
       $ts['sort'] = 'asc';
       $image = '';
     }
-    $cell_content = \Drupal::l(String::format('@cell_content@image', array('@cell_content' => $cell_content, '@image' => $image)), new Url('<current>', [], [
+    $cell_content = \Drupal::l(SafeMarkup::format('@cell_content@image', array('@cell_content' => $cell_content, '@image' => $image)), new Url('<current>', [], [
       'attributes' => array('title' => $title),
       'query' => array_merge($ts['query'], array(
         'sort' => $ts['sort'],
diff --git a/core/lib/Drupal/Component/Gettext/PoStreamReader.php b/core/lib/Drupal/Component/Gettext/PoStreamReader.php
index 94218e6..3aadfb1 100644
--- a/core/lib/Drupal/Component/Gettext/PoStreamReader.php
+++ b/core/lib/Drupal/Component/Gettext/PoStreamReader.php
@@ -10,6 +10,7 @@
 use Drupal\Component\Gettext\PoReaderInterface;
 use Drupal\Component\Gettext\PoStreamInterface;
 use Drupal\Component\Gettext\PoHeader;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -298,7 +299,7 @@ private function readLine() {
         }
         else {
           // A comment following any other context is a syntax error.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: "msgstr" was expected but not found on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr" was expected but not found on line %line.', $log_vars);
           return FALSE;
         }
         return;
@@ -308,7 +309,7 @@ private function readLine() {
 
         if ($this->_context != 'MSGID') {
           // A plural form can only be added to an msgid directly.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: "msgid_plural" was expected but not found on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgid_plural" was expected but not found on line %line.', $log_vars);
           return FALSE;
         }
 
@@ -319,7 +320,7 @@ private function readLine() {
         $quoted = $this->parseQuoted($line);
         if ($quoted === FALSE) {
           // The plural form must be wrapped in quotes.
-          $this->_errors[] = String::format('The translation stream %uri contains a syntax error on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains a syntax error on line %line.', $log_vars);
           return FALSE;
         }
 
@@ -346,7 +347,7 @@ private function readLine() {
         }
         elseif ($this->_context == 'MSGID') {
           // We are currently already in the context, meaning we passed an id with no data.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: "msgid" is unexpected on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgid" is unexpected on line %line.', $log_vars);
           return FALSE;
         }
 
@@ -357,7 +358,7 @@ private function readLine() {
         $quoted = $this->parseQuoted($line);
         if ($quoted === FALSE) {
           // The message id must be wrapped in quotes.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: invalid format for "msgid" on line %line.', $log_vars, $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgid" on line %line.', $log_vars, $log_vars);
           return FALSE;
         }
 
@@ -375,7 +376,7 @@ private function readLine() {
         }
         elseif (!empty($this->_current_item['msgctxt'])) {
           // A context cannot apply to another context.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: "msgctxt" is unexpected on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgctxt" is unexpected on line %line.', $log_vars);
           return FALSE;
         }
 
@@ -386,7 +387,7 @@ private function readLine() {
         $quoted = $this->parseQuoted($line);
         if ($quoted === FALSE) {
           // The context string must be quoted.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: invalid format for "msgctxt" on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgctxt" on line %line.', $log_vars);
           return FALSE;
         }
 
@@ -404,13 +405,13 @@ private function readLine() {
             ($this->_context != 'MSGSTR_ARR')) {
           // Plural message strings must come after msgid, msgxtxt,
           // msgid_plural, or other msgstr[] entries.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: "msgstr[]" is unexpected on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr[]" is unexpected on line %line.', $log_vars);
           return FALSE;
         }
 
         // Ensure the plurality is terminated.
         if (strpos($line, ']') === FALSE) {
-          $this->_errors[] = String::format('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
           return FALSE;
         }
 
@@ -425,7 +426,7 @@ private function readLine() {
         $quoted = $this->parseQuoted($line);
         if ($quoted === FALSE) {
           // The string must be quoted.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
           return FALSE;
         }
         if (!isset($this->_current_item['msgstr']) || !is_array($this->_current_item['msgstr'])) {
@@ -442,7 +443,7 @@ private function readLine() {
 
         if (($this->_context != 'MSGID') && ($this->_context != 'MSGCTXT')) {
           // Strings are only valid within an id or context scope.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: "msgstr" is unexpected on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr" is unexpected on line %line.', $log_vars);
           return FALSE;
         }
 
@@ -453,7 +454,7 @@ private function readLine() {
         $quoted = $this->parseQuoted($line);
         if ($quoted === FALSE) {
           // The string must be quoted.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: invalid format for "msgstr" on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr" on line %line.', $log_vars);
           return FALSE;
         }
 
@@ -468,7 +469,7 @@ private function readLine() {
         $quoted = $this->parseQuoted($line);
         if ($quoted === FALSE) {
           // This string must be quoted.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: string continuation expected on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: string continuation expected on line %line.', $log_vars);
           return FALSE;
         }
 
@@ -498,7 +499,7 @@ private function readLine() {
         }
         else {
           // No valid context to append to.
-          $this->_errors[] = String::format('The translation stream %uri contains an error: unexpected string on line %line.', $log_vars);
+          $this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: unexpected string on line %line.', $log_vars);
           return FALSE;
         }
         return;
@@ -511,7 +512,7 @@ private function readLine() {
       $this->_current_item = array();
     }
     elseif ($this->_context != 'COMMENT') {
-      $this->_errors[] = String::format('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
+      $this->_errors[] = SafeMarkup::format('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
       return FALSE;
     }
   }
diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php
index 1564f82..ae060d7 100644
--- a/core/lib/Drupal/Component/Utility/UrlHelper.php
+++ b/core/lib/Drupal/Component/Utility/UrlHelper.php
@@ -244,7 +244,7 @@ public static function externalIsLocal($url, $base_url) {
     $base_parts = parse_url($base_url);
 
     if (empty($base_parts['host']) || empty($url_parts['host'])) {
-      throw new \InvalidArgumentException(String::format('A path was passed when a fully qualified domain was expected.'));
+      throw new \InvalidArgumentException(SafeMarkup::format('A path was passed when a fully qualified domain was expected.'));
     }
 
     if (!isset($url_parts['path']) || !isset($base_parts['path'])) {
diff --git a/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php b/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php
index 2c6ed49..90d4a18 100644
--- a/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php
+++ b/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Breadcrumb;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
@@ -95,7 +96,7 @@ public function build(RouteMatchInterface $route_match) {
         break;
       }
       else {
-        throw new \UnexpectedValueException(String::format('Invalid breadcrumb returned by !class::build().', array('!class' => get_class($builder))));
+        throw new \UnexpectedValueException(SafeMarkup::format('Invalid breadcrumb returned by !class::build().', array('!class' => get_class($builder))));
       }
     }
     // Allow modules to alter the breadcrumb.
diff --git a/core/lib/Drupal/Core/Cache/CacheContexts.php b/core/lib/Drupal/Core/Cache/CacheContexts.php
index 781f24a..0ca1952 100644
--- a/core/lib/Drupal/Core/Cache/CacheContexts.php
+++ b/core/lib/Drupal/Core/Cache/CacheContexts.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Cache;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
@@ -111,7 +112,7 @@ public function convertTokensToKeys(array $context_tokens) {
     foreach (static::parseTokens($context_tokens) as $context) {
       list($context_id, $parameter) = $context;
       if (!in_array($context_id, $this->contexts)) {
-        throw new \InvalidArgumentException(String::format('"@context" is not a valid cache context ID.', ['@context' => $context_id]));
+        throw new \InvalidArgumentException(SafeMarkup::format('"@context" is not a valid cache context ID.', ['@context' => $context_id]));
       }
       $keys[] = $this->getService($context_id)->getContext($parameter);
     }
diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php
index e94db9b..d8870f0 100644
--- a/core/lib/Drupal/Core/Config/ConfigBase.php
+++ b/core/lib/Drupal/Core/Config/ConfigBase.php
@@ -8,6 +8,7 @@
 namespace Drupal\Core\Config;
 
 use Drupal\Component\Utility\NestedArray;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
 
@@ -95,13 +96,13 @@ public function setName($name) {
   public static function validateName($name) {
     // The name must be namespaced by owner.
     if (strpos($name, '.') === FALSE) {
-      throw new ConfigNameException(String::format('Missing namespace in Config object name @name.', array(
+      throw new ConfigNameException(SafeMarkup::format('Missing namespace in Config object name @name.', array(
         '@name' => $name,
       )));
     }
     // The name must be shorter than Config::MAX_NAME_LENGTH characters.
     if (strlen($name) > self::MAX_NAME_LENGTH) {
-      throw new ConfigNameException(String::format('Config object name @name exceeds maximum allowed length of @length characters.', array(
+      throw new ConfigNameException(SafeMarkup::format('Config object name @name exceeds maximum allowed length of @length characters.', array(
         '@name' => $name,
         '@length' => self::MAX_NAME_LENGTH,
       )));
@@ -110,7 +111,7 @@ public static function validateName($name) {
     // The name must not contain any of the following characters:
     // : ? * < > " ' / \
     if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) {
-      throw new ConfigNameException(String::format('Invalid character in Config object name @name.', array(
+      throw new ConfigNameException(SafeMarkup::format('Invalid character in Config object name @name.', array(
         '@name' => $name,
       )));
     }
@@ -220,7 +221,7 @@ public function set($key, $value) {
   protected function validateKeys(array $data) {
     foreach ($data as $key => $value) {
       if (strpos($key, '.') !== FALSE) {
-        throw new ConfigValueException(String::format('@key key contains a dot which is not supported.', array('@key' => $key)));
+        throw new ConfigValueException(SafeMarkup::format('@key key contains a dot which is not supported.', array('@key' => $key)));
       }
       if (is_array($value)) {
         $this->validateKeys($value);
diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php
index 3f7db46..e40a4f0 100644
--- a/core/lib/Drupal/Core/Config/ConfigImporter.php
+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -946,7 +946,7 @@ protected function importInvokeOwner($collection, $op, $name) {
       // Call to the configuration entity's storage to handle the configuration
       // change.
       if (!($entity_storage instanceof ImportableEntityStorageInterface)) {
-        throw new EntityStorageException(String::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type)));
+        throw new EntityStorageException(SafeMarkup::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type)));
       }
       $entity_storage->$method($name, $new_config, $old_config);
       $this->setProcessedConfiguration($collection, $op, $name);
@@ -992,7 +992,7 @@ protected function importInvokeRename($collection, $rename_name) {
     // Call to the configuration entity's storage to handle the configuration
     // change.
     if (!($entity_storage instanceof ImportableEntityStorageInterface)) {
-      throw new EntityStorageException(String::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type_id)));
+      throw new EntityStorageException(SafeMarkup::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type_id)));
     }
     $entity_storage->importRename($names['old_name'], $new_config, $old_config);
     $this->setProcessedConfiguration($collection, 'rename', $rename_name);
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
index 90837f9..863554a 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Config\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Config\ConfigException;
@@ -264,7 +265,7 @@ public function toArray() {
     $config_name = $this->getEntityType()->getConfigPrefix() . '.' . $this->id();
     $definition = $this->getTypedConfig()->getDefinition($config_name);
     if (!isset($definition['mapping'])) {
-      throw new SchemaIncompleteException(String::format('Incomplete or missing schema for @config_name', array('@config_name' => $config_name)));
+      throw new SchemaIncompleteException(SafeMarkup::format('Incomplete or missing schema for @config_name', array('@config_name' => $config_name)));
     }
     $id_key = $this->getEntityType()->getKey('id');
     foreach (array_keys($definition['mapping']) as $name) {
@@ -313,7 +314,7 @@ public function preSave(EntityStorageInterface $storage) {
       ->execute();
     $matched_entity = reset($matching_entities);
     if (!empty($matched_entity) && ($matched_entity != $this->id()) && $matched_entity != $this->getOriginalId()) {
-      throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity)));
+      throw new ConfigDuplicateUUIDException(SafeMarkup::format('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity)));
     }
 
     // If this entity is not new, load the original entity for comparison.
@@ -321,7 +322,7 @@ public function preSave(EntityStorageInterface $storage) {
       $original = $storage->loadUnchanged($this->getOriginalId());
       // Ensure that the UUID cannot be changed for an existing entity.
       if ($original && ($original->uuid() != $this->uuid())) {
-        throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid())));
+        throw new ConfigDuplicateUUIDException(SafeMarkup::format('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid())));
       }
     }
     if (!$this->isSyncing()) {
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
index 27da150..cfbf0b4 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Config\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Config\ConfigImporterException;
@@ -229,7 +230,7 @@ public function save(EntityInterface $entity) {
     // @todo Consider moving this to a protected method on the parent class, and
     //   abstracting it for all entity types.
     if (strlen($entity->get($this->idKey)) > self::MAX_ID_LENGTH) {
-      throw new ConfigEntityIdLengthException(String::format('Configuration entity ID @id exceeds maximum allowed length of @length characters.', array(
+      throw new ConfigEntityIdLengthException(SafeMarkup::format('Configuration entity ID @id exceeds maximum allowed length of @length characters.', array(
         '@id' => $entity->get($this->idKey),
         '@length' => self::MAX_ID_LENGTH,
       )));
@@ -362,7 +363,7 @@ public function importUpdate($name, Config $new_config, Config $old_config) {
     $id = static::getIDFromConfigName($name, $this->entityType->getConfigPrefix());
     $entity = $this->load($id);
     if (!$entity) {
-      throw new ConfigImporterException(String::format('Attempt to update non-existing entity "@id".', array('@id' => $id)));
+      throw new ConfigImporterException(SafeMarkup::format('Attempt to update non-existing entity "@id".', array('@id' => $id)));
     }
     $entity->setSyncing(TRUE);
     $entity = $this->updateFromStorageRecord($entity, $new_config->get());
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
index a363155..e66a11f 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Config\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Config\Entity\Exception\ConfigEntityStorageClassException;
 use Drupal\Core\Entity\EntityType;
 use Drupal\Core\Config\ConfigPrefixLengthException;
@@ -104,7 +105,7 @@ public function getConfigPrefix() {
     }
 
     if (strlen($config_prefix) > static::PREFIX_LENGTH) {
-      throw new ConfigPrefixLengthException(String::format('The configuration file name prefix @config_prefix exceeds the maximum character limit of @max_char.', array(
+      throw new ConfigPrefixLengthException(SafeMarkup::format('The configuration file name prefix @config_prefix exceeds the maximum character limit of @max_char.', array(
         '@config_prefix' => $config_prefix,
         '@max_char' => static::PREFIX_LENGTH,
       )));
@@ -169,7 +170,7 @@ public function setStorageClass($class) {
    */
   protected function checkStorageClass($class) {
     if (!is_a($class, 'Drupal\Core\Config\Entity\ConfigEntityStorage', TRUE)) {
-      throw new ConfigEntityStorageClassException(String::format('@class is not \Drupal\Core\Config\Entity\ConfigEntityStorage or it does not extend it', ['@class' => $class]));
+      throw new ConfigEntityStorageClassException(SafeMarkup::format('@class is not \Drupal\Core\Config\Entity\ConfigEntityStorage or it does not extend it', ['@class' => $class]));
     }
   }
 
diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php
index f404480..ecfbf2f 100644
--- a/core/lib/Drupal/Core/Config/FileStorage.php
+++ b/core/lib/Drupal/Core/Config/FileStorage.php
@@ -9,6 +9,7 @@
 
 use Drupal\Component\Serialization\Yaml;
 use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -101,7 +102,7 @@ public function read($name) {
       $data = $this->decode($data);
     }
     catch (InvalidDataTypeException $e) {
-      throw new UnsupportedDataTypeConfigException(String::format('Invalid data type in config @name: !message', array(
+      throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type in config @name: !message', array(
         '@name' => $name,
         '!message' => $e->getMessage(),
       )));
@@ -130,7 +131,7 @@ public function write($name, array $data) {
       $data = $this->encode($data);
     }
     catch (InvalidDataTypeException $e) {
-      throw new StorageException(String::format('Invalid data type in config @name: !message', array(
+      throw new StorageException(SafeMarkup::format('Invalid data type in config @name: !message', array(
         '@name' => $name,
         '!message' => $e->getMessage(),
       )));
diff --git a/core/lib/Drupal/Core/Config/ImmutableConfig.php b/core/lib/Drupal/Core/Config/ImmutableConfig.php
index 61e7fdd..a69b7c5 100644
--- a/core/lib/Drupal/Core/Config/ImmutableConfig.php
+++ b/core/lib/Drupal/Core/Config/ImmutableConfig.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Config;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -31,21 +32,21 @@ class ImmutableConfig extends Config {
    * {@inheritdoc}
    */
   public function set($key, $value) {
-    throw new ImmutableConfigException(String::format('Can not set values on immutable configuration !name:!key. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key]));
+    throw new ImmutableConfigException(SafeMarkup::format('Can not set values on immutable configuration !name:!key. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key]));
   }
 
   /**
    * {@inheritdoc}
    */
   public function clear($key) {
-    throw new ImmutableConfigException(String::format('Can not clear !key key in immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key]));
+    throw new ImmutableConfigException(SafeMarkup::format('Can not clear !key key in immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key]));
   }
 
   /**
    * {@inheritdoc}
    */
   public function save() {
-    throw new ImmutableConfigException(String::format('Can not save immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()]));
+    throw new ImmutableConfigException(SafeMarkup::format('Can not save immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()]));
   }
 
   /**
@@ -55,7 +56,7 @@ public function save() {
    *   The configuration object.
    */
   public function delete() {
-    throw new ImmutableConfigException(String::format('Can not delete immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()]));
+    throw new ImmutableConfigException(SafeMarkup::format('Can not delete immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()]));
   }
 
 }
diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php
index 06618d7..066f5b0 100644
--- a/core/lib/Drupal/Core/Config/InstallStorage.php
+++ b/core/lib/Drupal/Core/Config/InstallStorage.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Config;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Extension\ExtensionDiscovery;
 
 /**
@@ -90,7 +91,7 @@ public function getFilePath($name) {
     }
     // If any code in the early installer requests a configuration object that
     // does not exist anywhere as default config, then that must be mistake.
-    throw new StorageException(format_string('Missing configuration file: @name', array(
+    throw new StorageException(SafeMarkup::format('Missing configuration file: @name', array(
       '@name' => $name,
     )));
   }
diff --git a/core/lib/Drupal/Core/Config/PreExistingConfigException.php b/core/lib/Drupal/Core/Config/PreExistingConfigException.php
index 8fe8a6a..2408a24 100644
--- a/core/lib/Drupal/Core/Config/PreExistingConfigException.php
+++ b/core/lib/Drupal/Core/Config/PreExistingConfigException.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Config;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -61,7 +62,7 @@ public function getExtension() {
    * @return \Drupal\Core\Config\PreExistingConfigException
    */
   public static function create($extension, array $config_objects) {
-    $message = String::format('Configuration objects (@config_names) provided by @extension already exist in active configuration',
+    $message = SafeMarkup::format('Configuration objects (@config_names) provided by @extension already exist in active configuration',
       array(
         '@config_names' => implode(', ', static::flattenConfigObjects($config_objects)),
         '@extension' => $extension
diff --git a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php
index 1b314ac..35e932a 100644
--- a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php
+++ b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\Core\Config\Schema;
 
-use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Config\TypedConfigManagerInterface;
 use Drupal\Core\TypedData\TypedData;
 
@@ -94,7 +94,7 @@ public function get($name) {
       return $element;
     }
     else {
-      throw new \InvalidArgumentException(String::format("The configuration property @key doesn't exist.", array('@key' => $name)));
+      throw new \InvalidArgumentException(SafeMarkup::format("The configuration property @key doesn't exist.", array('@key' => $name)));
     }
   }
 
diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php
index 4af470e..63caa29 100644
--- a/core/lib/Drupal/Core/Config/StorableConfigBase.php
+++ b/core/lib/Drupal/Core/Config/StorableConfigBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Config;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Config\Schema\Ignore;
 use Drupal\Core\TypedData\PrimitiveInterface;
@@ -156,7 +157,7 @@ protected function validateValue($key, $value) {
       }
     }
     elseif ($value !== NULL && !is_scalar($value)) {
-      throw new UnsupportedDataTypeConfigException(String::format('Invalid data type for config element @name:@key', array(
+      throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type for config element @name:@key', array(
         '@name' => $this->getName(),
         '@key' => $key,
       )));
@@ -206,7 +207,7 @@ protected function castValue($key, $value) {
     else {
       // Throw exception on any non-scalar or non-array value.
       if (!is_array($value)) {
-        throw new UnsupportedDataTypeConfigException(String::format('Invalid data type for config element @name:@key', array(
+        throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type for config element @name:@key', array(
           '@name' => $this->getName(),
           '@key' => $key,
         )));
diff --git a/core/lib/Drupal/Core/Config/StorageComparer.php b/core/lib/Drupal/Core/Config/StorageComparer.php
index e3e42d8..dda59e5 100644
--- a/core/lib/Drupal/Core/Config/StorageComparer.php
+++ b/core/lib/Drupal/Core/Config/StorageComparer.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Config;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Config\Entity\ConfigDependencyManager;
 use Drupal\Core\DependencyInjection\DependencySerializationTrait;
@@ -189,7 +190,7 @@ protected function addChangeList($collection, $op, array $changes, array $sort_o
       // ensure the array is keyed from 0.
       $this->changelist[$collection][$op] = array_values(array_intersect($sort_order, $this->changelist[$collection][$op]));
       if ($count != count($this->changelist[$collection][$op])) {
-        throw new \InvalidArgumentException(String::format('Sorting the @op changelist should not change its length.', array('@op' => $op)));
+        throw new \InvalidArgumentException(SafeMarkup::format('Sorting the @op changelist should not change its length.', array('@op' => $op)));
       }
     }
   }
diff --git a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php
index cc53975..9d4e309 100644
--- a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php
+++ b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Config\Testing;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Config\ConfigCrudEvent;
 use Drupal\Core\Config\ConfigEvents;
@@ -88,14 +89,14 @@ public function onConfigSave(ConfigCrudEvent $event) {
       $this->checked[$name . ':' . $checksum] = TRUE;
       $errors = $this->checkConfigSchema($this->typedManager, $name, $data);
       if ($errors === FALSE) {
-        throw new SchemaIncompleteException(String::format('No schema for @config_name', array('@config_name' => $name)));
+        throw new SchemaIncompleteException(SafeMarkup::format('No schema for @config_name', array('@config_name' => $name)));
       }
       elseif (is_array($errors)) {
         $text_errors = [];
         foreach ($errors as $key => $error) {
-          $text_errors[] = String::format('@key @error', array('@key' => $key, '@error' => $error));
+          $text_errors[] = SafeMarkup::format('@key @error', array('@key' => $key, '@error' => $error));
         }
-        throw new SchemaIncompleteException(String::format('Schema errors for @config_name with the following errors: @errors', array('@config_name' => $name, '@errors' => implode(', ', $text_errors))));
+        throw new SchemaIncompleteException(SafeMarkup::format('Schema errors for @config_name with the following errors: @errors', array('@config_name' => $name, '@errors' => implode(', ', $text_errors))));
       }
     }
   }
diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php
index 5f71e6b..e938862 100644
--- a/core/lib/Drupal/Core/Config/TypedConfigManager.php
+++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php
@@ -8,7 +8,7 @@
 namespace Drupal\Core\Config;
 
 use Drupal\Component\Utility\NestedArray;
-use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Config\Schema\ArrayElement;
 use Drupal\Core\Config\Schema\ConfigSchemaAlterException;
@@ -324,7 +324,7 @@ protected function alterDefinitions(&$definitions) {
       else {
         $message = 'Invoking hook_config_schema_info_alter() has removed (@removed) schema definitions';
       }
-      throw new ConfigSchemaAlterException(String::format($message, ['@added' => implode(',', $added_keys), '@removed' => implode(',', $removed_keys)]));
+      throw new ConfigSchemaAlterException(SafeMarkup::format($message, ['@added' => implode(',', $added_keys), '@removed' => implode(',', $removed_keys)]));
     }
   }
 
diff --git a/core/lib/Drupal/Core/Config/UnmetDependenciesException.php b/core/lib/Drupal/Core/Config/UnmetDependenciesException.php
index 6a10003..5008c0c 100644
--- a/core/lib/Drupal/Core/Config/UnmetDependenciesException.php
+++ b/core/lib/Drupal/Core/Config/UnmetDependenciesException.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Config;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\StringTranslation\TranslationInterface;
 
@@ -80,7 +81,7 @@ public function getTranslatedMessage(TranslationInterface $string_translation, $
    * @return \Drupal\Core\Config\PreExistingConfigException
    */
   public static function create($extension, array $config_objects) {
-    $message = String::format('Configuration objects (@config_names) provided by @extension have unmet dependencies',
+    $message = SafeMarkup::format('Configuration objects (@config_names) provided by @extension have unmet dependencies',
       array(
         '@config_names' => implode(', ', $config_objects),
         '@extension' => $extension
diff --git a/core/lib/Drupal/Core/Database/Driver/fake/FakeSelect.php b/core/lib/Drupal/Core/Database/Driver/fake/FakeSelect.php
index 7e6a1e7..37b0955 100644
--- a/core/lib/Drupal/Core/Database/Driver/fake/FakeSelect.php
+++ b/core/lib/Drupal/Core/Database/Driver/fake/FakeSelect.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Database\Driver\fake;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Database\Connection;
 use Drupal\Core\Database\Query\Condition;
@@ -521,7 +522,7 @@ public function fields($table_alias, array $fields = array()) {
         $fields = array_keys(reset($this->databaseContents[$table]));
       }
       else {
-        throw new \Exception(String::format('All fields on empty table @table is not supported.', array('@table' => $table)));
+        throw new \Exception(SafeMarkup::format('All fields on empty table @table is not supported.', array('@table' => $table)));
       }
     }
     return parent::fields($table_alias, $fields);
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php
index d315b27..c8f2b04 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\Plugin\DataType\EntityReference;
 use Drupal\Core\Language\Language;
@@ -221,7 +222,7 @@ public function postCreate(EntityStorageInterface $storage) {
   public function setNewRevision($value = TRUE) {
 
     if (!$this->getEntityType()->hasKey('revision')) {
-      throw new \LogicException(String::format('Entity type @entity_type does not support revisions.', ['@entity_type' => $this->getEntityTypeId()]));
+      throw new \LogicException(SafeMarkup::format('Entity type @entity_type does not support revisions.', ['@entity_type' => $this->getEntityTypeId()]));
     }
 
     if ($value && !$this->newRevision) {
@@ -360,7 +361,7 @@ public function get($field_name) {
   protected function getTranslatedField($name, $langcode) {
     if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) {
       $message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.';
-      throw new \InvalidArgumentException(String::format($message, array('@langcode' => $this->activeLangcode)));
+      throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $this->activeLangcode)));
     }
     // Populate $this->fields to speed-up further look-ups and to keep track of
     // fields objects, possibly holding changes to field values.
@@ -565,7 +566,7 @@ public function onChange($name) {
           // Update the default internal language cache.
           $this->setDefaultLangcode();
           if (isset($this->translations[$this->defaultLangcode])) {
-            $message = String::format('A translation already exists for the specified language (@langcode).', array('@langcode' => $this->defaultLangcode));
+            $message = SafeMarkup::format('A translation already exists for the specified language (@langcode).', array('@langcode' => $this->defaultLangcode));
             throw new \InvalidArgumentException($message);
           }
           $this->updateFieldLangcodes($this->defaultLangcode);
@@ -576,7 +577,7 @@ public function onChange($name) {
           $items = $this->get($this->langcodeKey);
           if ($items->value != $this->activeLangcode) {
             $items->setValue($this->activeLangcode, FALSE);
-            $message = String::format('The translation language cannot be changed (@langcode).', array('@langcode' => $this->activeLangcode));
+            $message = SafeMarkup::format('The translation language cannot be changed (@langcode).', array('@langcode' => $this->activeLangcode));
             throw new \LogicException($message);
           }
         }
@@ -587,7 +588,7 @@ public function onChange($name) {
         //   read-only. See https://www.drupal.org/node/2443991.
         if (isset($this->values[$this->defaultLangcodeKey])) {
           $this->get($this->defaultLangcodeKey)->setValue($this->isDefaultTranslation(), FALSE);
-          $message = String::format('The default translation flag cannot be changed (@langcode).', array('@langcode' => $this->activeLangcode));
+          $message = SafeMarkup::format('The default translation flag cannot be changed (@langcode).', array('@langcode' => $this->activeLangcode));
           throw new \LogicException($message);
         }
         break;
@@ -635,7 +636,7 @@ public function getTranslation($langcode) {
 
     if (empty($translation)) {
       $message = 'Invalid translation language (@langcode) specified.';
-      throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode)));
+      throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $langcode)));
     }
 
     return $translation;
@@ -704,7 +705,7 @@ public function addTranslation($langcode, array $values = array()) {
     $this->getLanguages();
     if (!isset($this->languages[$langcode]) || $this->hasTranslation($langcode)) {
       $message = 'Invalid translation language (@langcode) specified.';
-      throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode)));
+      throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $langcode)));
     }
 
     // Instantiate a new empty entity so default values will be populated in the
@@ -755,7 +756,7 @@ public function removeTranslation($langcode) {
     }
     else {
       $message = 'The specified translation (@langcode) cannot be removed.';
-      throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode)));
+      throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $langcode)));
     }
   }
 
@@ -898,7 +899,7 @@ public function __unset($name) {
   public function createDuplicate() {
     if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) {
       $message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.';
-      throw new \InvalidArgumentException(String::format($message, array('@langcode' => $this->activeLangcode)));
+      throw new \InvalidArgumentException(SafeMarkup::format($message, array('@langcode' => $this->activeLangcode)));
     }
 
     $duplicate = clone $this;
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
index d1beeeb..1d5fc0b 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
@@ -60,7 +61,7 @@ protected function doCreate(array $values) {
     $bundle = FALSE;
     if ($this->bundleKey) {
       if (!isset($values[$this->bundleKey])) {
-        throw new EntityStorageException(String::format('Missing bundle for entity type @type', array('@type' => $this->entityTypeId)));
+        throw new EntityStorageException(SafeMarkup::format('Missing bundle for entity type @type', array('@type' => $this->entityTypeId)));
       }
       $bundle = $values[$this->bundleKey];
     }
diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php
index 455607e..8f891f1 100644
--- a/core/lib/Drupal/Core/Entity/Entity.php
+++ b/core/lib/Drupal/Core/Entity/Entity.php
@@ -7,9 +7,9 @@
 
 namespace Drupal\Core\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\DependencyInjection\DependencySerializationTrait;
-use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException;
 use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException;
@@ -186,7 +186,7 @@ public function urlInfo($rel = 'canonical', array $options = []) {
         $uri = call_user_func($uri_callback, $this);
       }
       else {
-        throw new UndefinedLinkTemplateException(String::format('No link template "@rel" found for the "@entity_type" entity type', array(
+        throw new UndefinedLinkTemplateException(SafeMarkup::format('No link template "@rel" found for the "@entity_type" entity type', array(
           '@rel' => $rel,
           '@entity_type' => $this->getEntityTypeId(),
         )));
@@ -371,7 +371,7 @@ public function preSave(EntityStorageInterface $storage) {
     if ($this->getEntityType()->getBundleOf()) {
       // Throw an exception if the bundle ID is longer than 32 characters.
       if (Unicode::strlen($this->id()) > EntityTypeInterface::BUNDLE_MAX_LENGTH) {
-        throw new ConfigEntityIdLengthException(String::format(
+        throw new ConfigEntityIdLengthException(SafeMarkup::format(
           'Attempt to create a bundle with an ID longer than @max characters: @id.', array(
             '@max' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
             '@id' => $this->id(),
diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
index 1197801..b8b27ce 100644
--- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Config\Entity\ConfigEntityBase;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Entity\Display\EntityDisplayInterface;
@@ -254,7 +255,7 @@ public function calculateDependencies() {
       // If the target entity type uses entities to manage its bundles then
       // depend on the bundle entity.
       if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->bundle)) {
-        throw new \LogicException(String::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->bundle)));
+        throw new \LogicException(SafeMarkup::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->bundle)));
       }
       $this->addDependency('config', $bundle_entity->getConfigDependencyName());
     }
diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php
index 3ab60f5..a4b38fb 100644
--- a/core/lib/Drupal/Core/Entity/EntityManager.php
+++ b/core/lib/Drupal/Core/Entity/EntityManager.php
@@ -9,6 +9,7 @@
 
 use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
 use Drupal\Component\Plugin\Exception\PluginNotFoundException;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
@@ -405,7 +406,7 @@ protected function buildBaseFieldDefinitions($entity_type_id) {
 
     // Fail with an exception for non-fieldable entity types.
     if (!$entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) {
-      throw new \LogicException(String::format('Getting the base fields is not supported for entity type @type.', array('@type' => $entity_type->getLabel())));
+      throw new \LogicException(SafeMarkup::format('Getting the base fields is not supported for entity type @type.', array('@type' => $entity_type->getLabel())));
     }
 
     // Retrieve base field definitions.
@@ -473,19 +474,19 @@ protected function buildBaseFieldDefinitions($entity_type_id) {
     // translatable values.
     foreach (array_intersect_key($keys, array_flip(['id', 'revision', 'uuid', 'bundle'])) as $key => $field_name) {
       if (!isset($base_field_definitions[$field_name])) {
-        throw new \LogicException(String::format('The @field field definition does not exist and it is used as @key entity key.', array(
+        throw new \LogicException(SafeMarkup::format('The @field field definition does not exist and it is used as @key entity key.', array(
           '@field' => $base_field_definitions[$field_name]->getLabel(),
           '@key' => $key,
         )));
       }
       if ($base_field_definitions[$field_name]->isRevisionable()) {
-        throw new \LogicException(String::format('The @field field cannot be revisionable as it is used as @key entity key.', array(
+        throw new \LogicException(SafeMarkup::format('The @field field cannot be revisionable as it is used as @key entity key.', array(
           '@field' => $base_field_definitions[$field_name]->getLabel(),
           '@key' => $key,
         )));
       }
       if ($base_field_definitions[$field_name]->isTranslatable()) {
-        throw new \LogicException(String::format('The @field field cannot be translatable as it is used as @key entity key.', array(
+        throw new \LogicException(SafeMarkup::format('The @field field cannot be translatable as it is used as @key entity key.', array(
           '@field' => $base_field_definitions[$field_name]->getLabel(),
           '@key' => $key,
         )));
@@ -494,7 +495,7 @@ protected function buildBaseFieldDefinitions($entity_type_id) {
 
     // Make sure translatable entity types define the "langcode" field properly.
     if ($entity_type->isTranslatable() && (!isset($keys['langcode']) || !isset($base_field_definitions[$keys['langcode']]) || !$base_field_definitions[$keys['langcode']]->isTranslatable())) {
-      throw new \LogicException(String::format('The @entity_type entity type cannot be translatable as it does not define a translatable "langcode" field.', array('@entity_type' => $entity_type->getLabel())));
+      throw new \LogicException(SafeMarkup::format('The @entity_type entity type cannot be translatable as it does not define a translatable "langcode" field.', array('@entity_type' => $entity_type->getLabel())));
     }
 
     return $base_field_definitions;
diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php
index 3528b7d..8448a99 100644
--- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\Query\QueryInterface;
 
@@ -396,7 +397,7 @@ public function save(EntityInterface $entity) {
 
     // A new entity should not already exist.
     if ($id_exists && $is_new) {
-      throw new EntityStorageException(String::format('@type entity with ID @id already exists.', array('@type' => $this->entityTypeId, '@id' => $id)));
+      throw new EntityStorageException(SafeMarkup::format('@type entity with ID @id already exists.', array('@type' => $this->entityTypeId, '@id' => $id)));
     }
 
     // Load the original entity, if any.
diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php
index 38b6170..2b9c268 100644
--- a/core/lib/Drupal/Core/Entity/EntityType.php
+++ b/core/lib/Drupal/Core/Entity/EntityType.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\Core\Entity;
 
-use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Entity\Exception\EntityTypeIdLengthException;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -238,7 +238,7 @@ class EntityType implements EntityTypeInterface {
   public function __construct($definition) {
     // Throw an exception if the entity type ID is longer than 32 characters.
     if (Unicode::strlen($definition['id']) > static::ID_MAX_LENGTH) {
-      throw new EntityTypeIdLengthException(String::format(
+      throw new EntityTypeIdLengthException(SafeMarkup::format(
         'Attempt to create an entity type with an ID longer than @max characters: @id.', array(
           '@max' => static::ID_MAX_LENGTH,
           '@id' => $definition['id'],
diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php
index 365020c..bf75189 100644
--- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php
+++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Entity\KeyValueStore;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Uuid\UuidInterface;
 use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException;
@@ -167,7 +168,7 @@ public function save(EntityInterface $entity) {
     // @todo This is not config-specific, but serial IDs will likely never hit
     //   this limit. Consider renaming the exception class.
     if (strlen($entity->id()) > static::MAX_ID_LENGTH) {
-      throw new ConfigEntityIdLengthException(String::format('Entity ID @id exceeds maximum allowed length of @length characters.', array(
+      throw new ConfigEntityIdLengthException(SafeMarkup::format('Entity ID @id exceeds maximum allowed length of @length characters.', array(
         '@id' => $entity->id(),
         '@length' => static::MAX_ID_LENGTH,
       )));
diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php
index bbcb0bb..46bd6f9 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Entity\Plugin\DataType;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\FieldableEntityInterface;
 use Drupal\Core\Entity\EntityInterface;
@@ -81,12 +82,12 @@ public function setValue($entity, $notify = TRUE) {
    */
   public function get($property_name) {
     if (!isset($this->entity)) {
-      throw new MissingDataException(String::format('Unable to get property @name as no entity has been provided.', array('@name' => $property_name)));
+      throw new MissingDataException(SafeMarkup::format('Unable to get property @name as no entity has been provided.', array('@name' => $property_name)));
     }
     if (!$this->entity instanceof FieldableEntityInterface) {
       // @todo: Add support for config entities in
       // https://www.drupal.org/node/1818574.
-      throw new \InvalidArgumentException(String::format('Unable to get unknown property @name.', array('@name' => $property_name)));
+      throw new \InvalidArgumentException(SafeMarkup::format('Unable to get unknown property @name.', array('@name' => $property_name)));
     }
     // This will throw an exception for unknown fields.
     return $this->entity->get($property_name);
@@ -97,12 +98,12 @@ public function get($property_name) {
    */
   public function set($property_name, $value, $notify = TRUE) {
     if (!isset($this->entity)) {
-      throw new MissingDataException(String::format('Unable to set property @name as no entity has been provided.', array('@name' => $property_name)));
+      throw new MissingDataException(SafeMarkup::format('Unable to set property @name as no entity has been provided.', array('@name' => $property_name)));
     }
     if (!$this->entity instanceof FieldableEntityInterface) {
       // @todo: Add support for config entities in
       // https://www.drupal.org/node/1818574.
-      throw new \InvalidArgumentException(String::format('Unable to set unknown property @name.', array('@name' => $property_name)));
+      throw new \InvalidArgumentException(SafeMarkup::format('Unable to set unknown property @name.', array('@name' => $property_name)));
     }
     // This will throw an exception for unknown fields.
     $this->entity->set($property_name, $value, $notify);
@@ -114,7 +115,7 @@ public function set($property_name, $value, $notify = TRUE) {
    */
   public function getProperties($include_computed = FALSE) {
     if (!isset($this->entity)) {
-      throw new MissingDataException(String::format('Unable to get properties as no entity has been provided.'));
+      throw new MissingDataException(SafeMarkup::format('Unable to get properties as no entity has been provided.'));
     }
     if (!$this->entity instanceof FieldableEntityInterface) {
       // @todo: Add support for config entities in
@@ -129,7 +130,7 @@ public function getProperties($include_computed = FALSE) {
    */
   public function toArray() {
     if (!isset($this->entity)) {
-      throw new MissingDataException(String::format('Unable to get property values as no entity has been provided.'));
+      throw new MissingDataException(SafeMarkup::format('Unable to get property values as no entity has been provided.'));
     }
     return $this->entity->toArray();
   }
diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
index 6e1ecf1..daa88bb 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Entity\Query\Sql;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Database\Query\SelectInterface;
 use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Entity\Query\QueryException;
@@ -216,7 +217,7 @@ public function addField($field, $type, $langcode) {
           $index_prefix .= "$next_index_prefix.";
         }
         else {
-          throw new QueryException(format_string('Invalid specifier @next.', array('@next' => $relationship_specifier)));
+          throw new QueryException(SafeMarkup::format('Invalid specifier @next.', array('@next' => $relationship_specifier)));
         }
       }
     }
@@ -248,7 +249,7 @@ protected function ensureEntityTable($index_prefix, $property, $type, $langcode,
         return $this->entityTables[$index_prefix . $table];
       }
     }
-    throw new QueryException(format_string('@property not found', array('@property' => $property)));
+    throw new QueryException(SafeMarkup::format('@property not found', array('@property' => $property)));
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php b/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php
index 909ae5f..1490b93 100644
--- a/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php
+++ b/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Entity\Sql;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\ContentEntityTypeInterface;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
@@ -178,7 +179,7 @@ public function getFieldTableName($field_name) {
     }
 
     if (!isset($result)) {
-      throw new SqlContentEntityStorageException(String::format('Table information not available for the "@field_name" field.', array('@field_name' => $field_name)));
+      throw new SqlContentEntityStorageException(SafeMarkup::format('Table information not available for the "@field_name" field.', array('@field_name' => $field_name)));
     }
 
     return $result;
@@ -211,7 +212,7 @@ public function getFieldColumnName(FieldStorageDefinitionInterface $storage_defi
       $column_name = !in_array($property_name, $this->getReservedColumns()) ? $field_name . '_' . $property_name : $property_name;
     }
     else {
-      throw new SqlContentEntityStorageException(String::format('Column information not available for the "@field_name" field.', array('@field_name' => $field_name)));
+      throw new SqlContentEntityStorageException(SafeMarkup::format('Column information not available for the "@field_name" field.', array('@field_name' => $field_name)));
     }
 
     return $column_name;
diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
index d4252b2..63dd1e2 100644
--- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
+++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Entity\Sql;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
@@ -283,7 +284,7 @@ public function setEntityType(EntityTypeInterface $entity_type) {
       $this->initTableLayout();
     }
     else {
-      throw new EntityStorageException(String::format('Unsupported entity type @id', array('@id' => $entity_type->id())));
+      throw new EntityStorageException(SafeMarkup::format('Unsupported entity type @id', array('@id' => $entity_type->id())));
     }
   }
 
@@ -1070,7 +1071,7 @@ protected function mapToStorageRecord(ContentEntityInterface $entity, $table_nam
     foreach ($table_mapping->getFieldNames($table_name) as $field_name) {
 
       if (empty($this->getFieldStorageDefinitions()[$field_name])) {
-        throw new EntityStorageException(String::format('Table mapping contains invalid field %field.', array('%field' => $field_name)));
+        throw new EntityStorageException(SafeMarkup::format('Table mapping contains invalid field %field.', array('%field' => $field_name)));
       }
       $definition = $this->getFieldStorageDefinitions()[$field_name];
       $columns = $table_mapping->getColumnNames($field_name);
diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
index ddf9d81..e2b75b2 100644
--- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
+++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Entity\Sql;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Database\Connection;
 use Drupal\Core\Database\DatabaseException;
@@ -262,7 +263,7 @@ public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeI
 
     // If a migration is required, we can't proceed.
     if ($this->requiresEntityDataMigration($entity_type, $original)) {
-      throw new EntityStorageException(String::format('The SQL storage cannot change the schema for an existing entity type with data.'));
+      throw new EntityStorageException(SafeMarkup::format('The SQL storage cannot change the schema for an existing entity type with data.'));
     }
 
     // If we have no data just recreate the entity schema from scratch.
@@ -443,7 +444,7 @@ public function finalizePurge(FieldStorageDefinitionInterface $storage_definitio
    */
   protected function checkEntityType(EntityTypeInterface $entity_type) {
     if ($entity_type->id() != $this->entityType->id()) {
-      throw new EntityStorageException(String::format('Unsupported entity type @id', array('@id' => $entity_type->id())));
+      throw new EntityStorageException(SafeMarkup::format('Unsupported entity type @id', array('@id' => $entity_type->id())));
     }
     return TRUE;
   }
@@ -506,7 +507,7 @@ protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $res
         }
         foreach ($table_mapping->getFieldNames($table_name) as $field_name) {
           if (!isset($storage_definitions[$field_name])) {
-            throw new FieldException(String::format('Field storage definition for "@field_name" could not be found.', array('@field_name' => $field_name)));
+            throw new FieldException(SafeMarkup::format('Field storage definition for "@field_name" could not be found.', array('@field_name' => $field_name)));
           }
           // Add the schema for base field definitions.
           elseif ($table_mapping->allowsSharedTableStorage($storage_definitions[$field_name])) {
@@ -1396,7 +1397,7 @@ protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $st
 
     // Check that the schema does not include forbidden column names.
     if (array_intersect(array_keys($field_schema['columns']), $this->storage->getTableMapping()->getReservedColumns())) {
-      throw new FieldException(format_string('Illegal field column names on @field_name', array('@field_name' => $storage_definition->getName())));
+      throw new FieldException(SafeMarkup::format('Illegal field column names on @field_name', array('@field_name' => $storage_definition->getName())));
     }
 
     $field_name = $storage_definition->getName();
@@ -1620,7 +1621,7 @@ protected function getDedicatedTableSchema(FieldStorageDefinitionInterface $stor
     $properties = $storage_definition->getPropertyDefinitions();
     $table_mapping = $this->storage->getTableMapping();
     if (array_intersect(array_keys($schema['columns']), $table_mapping->getReservedColumns())) {
-      throw new FieldException(format_string('Illegal field column names on @field_name', array('@field_name' => $storage_definition->getName())));
+      throw new FieldException(SafeMarkup::format('Illegal field column names on @field_name', array('@field_name' => $storage_definition->getName())));
     }
 
     // Add field columns.
diff --git a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php
index b3d2202..d31fb18 100644
--- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php
@@ -107,7 +107,7 @@ protected function onHtml(GetResponseForExceptionEvent $event) {
       }
       // Do not translate the string to avoid errors producing more errors.
       unset($error['backtrace']);
-      $message = String::format('%type: !message in %function (line %line of %file).', $error);
+      $message = SafeMarkup::format('%type: !message in %function (line %line of %file).', $error);
 
       // Check if verbose error reporting is on.
       if ($this->getErrorLevel() == ERROR_REPORTING_DISPLAY_VERBOSE) {
diff --git a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php
index a32fa71..e43d00e 100644
--- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\Core\EventSubscriber;
 
-use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Render\BareHtmlPageRendererInterface;
@@ -104,7 +104,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) {
         // Deliver the 503 page if the site is in maintenance mode and the
         // logged in user is not allowed to bypass it.
         drupal_maintenance_theme();
-        $content = Xss::filterAdmin(String::format($this->config->get('system.maintenance')->get('message'), array(
+        $content = Xss::filterAdmin(SafeMarkup::format($this->config->get('system.maintenance')->get('message'), array(
           '@site' => $this->config->get('system.site')->get('name'),
         )));
         $output = $this->bareHtmlPageRenderer->renderBarePage(['#markup' => $content], $this->t('Site under maintenance'), 'maintenance_page');
diff --git a/core/lib/Drupal/Core/Extension/InfoParser.php b/core/lib/Drupal/Core/Extension/InfoParser.php
index 38ac624..cb178fb 100644
--- a/core/lib/Drupal/Core/Extension/InfoParser.php
+++ b/core/lib/Drupal/Core/Extension/InfoParser.php
@@ -9,7 +9,7 @@
 
 use Drupal\Component\Serialization\Yaml;
 use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
-use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Parses extension .info.yml files.
@@ -36,12 +36,12 @@ public function parse($filename) {
           static::$parsedInfos[$filename] = Yaml::decode(file_get_contents($filename));
         }
         catch (InvalidDataTypeException $e) {
-          $message = String::format("Unable to parse !file: !error", array('!file' => $filename, '!error' => $e->getMessage()));
+          $message = SafeMarkup::format("Unable to parse !file: !error", array('!file' => $filename, '!error' => $e->getMessage()));
           throw new InfoParserException($message);
         }
         $missing_keys = array_diff($this->getRequiredKeys(), array_keys(static::$parsedInfos[$filename]));
         if (!empty($missing_keys)) {
-          $message = String::format('Missing required keys (!missing_keys) in !file.', array('!missing_keys' => implode(', ', $missing_keys), '!file' => $filename));
+          $message = SafeMarkup::format('Missing required keys (!missing_keys) in !file.', array('!missing_keys' => implode(', ', $missing_keys), '!file' => $filename));
           throw new InfoParserException($message);
         }
         if (isset(static::$parsedInfos[$filename]['version']) && static::$parsedInfos[$filename]['version'] === 'VERSION') {
diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php
index c1eee71..3290364 100644
--- a/core/lib/Drupal/Core/Extension/ModuleHandler.php
+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -9,6 +9,7 @@
 
 use Drupal\Component\Graph\Graph;
 use Drupal\Component\Utility\NestedArray;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
@@ -581,7 +582,7 @@ protected function buildImplementationInfo($hook) {
         }
         // If a new implementation was added, verify that the function exists.
         if (!function_exists($module . '_' . $hook)) {
-          throw new \RuntimeException(String::format('An invalid implementation @function was added by hook_module_implements_alter()', array('@function' => $module . '_' . $hook)));
+          throw new \RuntimeException(SafeMarkup::format('An invalid implementation @function was added by hook_module_implements_alter()', array('@function' => $module . '_' . $hook)));
         }
       }
     }
diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
index 172bfc0..3793aa8 100644
--- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php
+++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
@@ -8,6 +8,7 @@
 namespace Drupal\Core\Extension;
 
 use Drupal\Component\Serialization\Yaml;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Config\PreExistingConfigException;
@@ -88,7 +89,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
       $module_list = $module_list ? array_combine($module_list, $module_list) : array();
       if ($missing_modules = array_diff_key($module_list, $module_data)) {
         // One or more of the given modules doesn't exist.
-        throw new MissingDependencyException(String::format('Unable to install modules %modules due to missing modules %missing.', array(
+        throw new MissingDependencyException(SafeMarkup::format('Unable to install modules %modules due to missing modules %missing.', array(
           '%modules' => implode(', ', $module_list),
           '%missing' => implode(', ', $missing_modules),
         )));
@@ -107,7 +108,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
         foreach (array_keys($module_data[$module]->requires) as $dependency) {
           if (!isset($module_data[$dependency])) {
             // The dependency does not exist.
-            throw new MissingDependencyException(String::format('Unable to install modules: module %module is missing its dependency module %dependency.', array(
+            throw new MissingDependencyException(SafeMarkup::format('Unable to install modules: module %module is missing its dependency module %dependency.', array(
               '%module' => $module,
               '%dependency' => $dependency,
             )));
@@ -145,7 +146,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
       if (!$enabled) {
         // Throw an exception if the module name is too long.
         if (strlen($module) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) {
-          throw new ExtensionNameLengthException(format_string('Module name %name is over the maximum allowed length of @max characters.', array(
+          throw new ExtensionNameLengthException(SafeMarkup::format('Module name %name is over the maximum allowed length of @max characters.', array(
             '%name' => $module,
             '@max' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
           )));
@@ -331,7 +332,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
       foreach ($reasons as $reason) {
         $reason_message[] = implode(', ', $reason);
       }
-      throw new ModuleUninstallValidatorException(format_string('The following reasons prevents the modules from being uninstalled: @reasons', array(
+      throw new ModuleUninstallValidatorException(SafeMarkup::format('The following reasons prevents the modules from being uninstalled: @reasons', array(
         '@reasons' => implode(', ', $reason_message),
       )));
     }
diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php
index 0c7ade4..7fbc7b9 100644
--- a/core/lib/Drupal/Core/Extension/ThemeHandler.php
+++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Extension;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Asset\AssetCollectionOptimizerInterface;
 use Drupal\Core\Cache\Cache;
@@ -199,7 +200,7 @@ public function install(array $theme_list, $install_dependencies = TRUE) {
 
       if ($missing = array_diff_key($theme_list, $theme_data)) {
         // One or more of the given themes doesn't exist.
-        throw new \InvalidArgumentException(String::format('Unknown themes: !themes.', array(
+        throw new \InvalidArgumentException(SafeMarkup::format('Unknown themes: !themes.', array(
           '!themes' => implode(', ', $missing),
         )));
       }
@@ -250,7 +251,7 @@ public function install(array $theme_list, $install_dependencies = TRUE) {
 
       // Throw an exception if the theme name is too long.
       if (strlen($key) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) {
-        throw new ExtensionNameLengthException(String::format('Theme name %name is over the maximum allowed length of @max characters.', array(
+        throw new ExtensionNameLengthException(SafeMarkup::format('Theme name %name is over the maximum allowed length of @max characters.', array(
           '%name' => $key,
           '@max' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
         )));
@@ -628,7 +629,7 @@ protected function resetSystem() {
   public function getName($theme) {
     $themes = $this->listInfo();
     if (!isset($themes[$theme])) {
-      throw new \InvalidArgumentException(String::format('Requested the name of a non-existing theme @theme', array('@theme' => $theme)));
+      throw new \InvalidArgumentException(SafeMarkup::format('Requested the name of a non-existing theme @theme', array('@theme' => $theme)));
     }
     return String::checkPlain($themes[$theme]->info['name']);
   }
diff --git a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php
index b6b2a3c..160316a 100644
--- a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php
+++ b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Field\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Field\BaseFieldDefinition;
@@ -89,10 +90,10 @@ public function __construct(array $values, $entity_type = 'base_field_override')
       throw new FieldException('Attempt to create a base field bundle override of a field without a field_name');
     }
     if (empty($values['entity_type'])) {
-      throw new FieldException(String::format('Attempt to create a base field bundle override of field @field_name without an entity_type', array('@field_name' => $values['field_name'])));
+      throw new FieldException(SafeMarkup::format('Attempt to create a base field bundle override of field @field_name without an entity_type', array('@field_name' => $values['field_name'])));
     }
     if (empty($values['bundle'])) {
-      throw new FieldException(String::format('Attempt to create a base field bundle override of field @field_name without a bundle', array('@field_name' => $values['field_name'])));
+      throw new FieldException(SafeMarkup::format('Attempt to create a base field bundle override of field @field_name without a bundle', array('@field_name' => $values['field_name'])));
     }
 
     parent::__construct($values, $entity_type);
@@ -174,10 +175,10 @@ public function preSave(EntityStorageInterface $storage) {
     else {
       // Some updates are always disallowed.
       if ($this->entity_type != $this->original->entity_type) {
-        throw new FieldException(String::format('Cannot change the entity_type of an existing base field bundle override (entity type:@entity_type, bundle:@bundle, field name: @field_name)', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type, '@bundle' => $this->original->bundle)));
+        throw new FieldException(SafeMarkup::format('Cannot change the entity_type of an existing base field bundle override (entity type:@entity_type, bundle:@bundle, field name: @field_name)', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type, '@bundle' => $this->original->bundle)));
       }
       if ($this->bundle != $this->original->bundle && empty($this->bundleRenameAllowed)) {
-        throw new FieldException(String::format('Cannot change the bundle of an existing base field bundle override (entity type:@entity_type, bundle:@bundle, field name: @field_name)', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type, '@bundle' => $this->original->bundle)));
+        throw new FieldException(SafeMarkup::format('Cannot change the bundle of an existing base field bundle override (entity type:@entity_type, bundle:@bundle, field name: @field_name)', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type, '@bundle' => $this->original->bundle)));
       }
       $previous_definition = $this->original;
     }
diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php
index 9a1acc0..6372906 100644
--- a/core/lib/Drupal/Core/Field/FieldConfigBase.php
+++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php
@@ -8,6 +8,7 @@
 namespace Drupal\Core\Field;
 
 use Drupal\Component\Plugin\DependentPluginInterface;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Config\Entity\ConfigEntityBase;
 use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Entity\FieldableEntityInterface;
@@ -254,7 +255,7 @@ public function calculateDependencies() {
     $bundle_entity_type_id = $this->entityManager()->getDefinition($this->entity_type)->getBundleEntityType();
     if ($bundle_entity_type_id != 'bundle') {
       if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->bundle)) {
-        throw new \LogicException(String::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->bundle)));
+        throw new \LogicException(SafeMarkup::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->bundle)));
       }
       $this->addDependency('config', $bundle_entity->getConfigDependencyName());
     }
diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php
index 8eb78dd..b44691c 100644
--- a/core/lib/Drupal/Core/Form/FormBuilder.php
+++ b/core/lib/Drupal/Core/Form/FormBuilder.php
@@ -10,6 +10,7 @@
 use Drupal\Component\Utility\Crypt;
 use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\NestedArray;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\UrlHelper;
 use Drupal\Core\Access\CsrfTokenGenerator;
@@ -139,7 +140,7 @@ public function getFormId($form_arg, FormStateInterface &$form_state) {
     }
 
     if (!is_object($form_arg) || !($form_arg instanceof FormInterface)) {
-      throw new \InvalidArgumentException(String::format('The form argument @form_arg is not a valid form.', array('@form_arg' => $form_arg)));
+      throw new \InvalidArgumentException(SafeMarkup::format('The form argument @form_arg is not a valid form.', array('@form_arg' => $form_arg)));
     }
 
     // Add the $form_arg as the callback object and determine the form ID.
diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php
index e4e9b9f..4fd6bdc 100644
--- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php
+++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php
@@ -8,7 +8,7 @@
 namespace Drupal\Core\ImageToolkit;
 
 use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
-use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Plugin\PluginBase;
 use Psr\Log\LoggerInterface;
 
@@ -114,7 +114,7 @@ protected function prepareArguments(array $arguments) {
       if ($argument['required']) {
         if (!array_key_exists($id, $arguments)) {
           // If the argument is required throw an exception.
-          throw new \InvalidArgumentException(String::format("Argument '@argument' expected by plugin '@plugin' but not passed", array('@argument' => $id, '@plugin' => $this->getPluginId())));
+          throw new \InvalidArgumentException(SafeMarkup::format("Argument '@argument' expected by plugin '@plugin' but not passed", array('@argument' => $id, '@plugin' => $this->getPluginId())));
         }
       }
       else {
@@ -124,7 +124,7 @@ protected function prepareArguments(array $arguments) {
         if (!array_key_exists('default', $argument)) {
           // The plugin did not define a default, so throw a plugin exception,
           // not an invalid argument exception.
-          throw new InvalidPluginDefinitionException(String::format("Default for argument '@argument' expected by plugin '@plugin' but not defined", array('@argument' => $id, '@plugin' => $this->getPluginId())));
+          throw new InvalidPluginDefinitionException(SafeMarkup::format("Default for argument '@argument' expected by plugin '@plugin' but not defined", array('@argument' => $id, '@plugin' => $this->getPluginId())));
         }
 
         // Use the default value if the argument is not passed in.
diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php
index dc4abaa..aea51ac 100644
--- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php
+++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php
@@ -77,7 +77,7 @@ function ($definition) use ($toolkit_id, $operation) {
     );
 
     if (!$definitions) {
-      $message = String::format("No image operation plugin for '@toolkit' toolkit and '@operation' operation.", array('@toolkit' => $toolkit_id, '@operation' => $operation));
+      $message = SafeMarkup::format("No image operation plugin for '@toolkit' toolkit and '@operation' operation.", array('@toolkit' => $toolkit_id, '@operation' => $operation));
       throw new PluginNotFoundException($toolkit_id . '.' . $operation, $message);
     }
     else {
diff --git a/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php b/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php
index 79d9082..147a0fc 100644
--- a/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php
+++ b/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Installer\Form;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\UserAgent;
 use Drupal\Core\Form\FormBase;
@@ -70,7 +71,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_
     );
     $form['help'] = array(
       '#type' => 'item',
-      '#markup' => String::format('<p>Translations will be downloaded from the <a href="http://localize.drupal.org">Drupal Translation website</a>.
+      '#markup' => SafeMarkup::format('<p>Translations will be downloaded from the <a href="http://localize.drupal.org">Drupal Translation website</a>.
       If you do not want this, select <a href="!english">English</a>.</p>', array(
           '!english' => install_full_redirect_url(array('parameters' => array('langcode' => 'en'))),
         )),
diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php
index 22c5289..20359cf 100644
--- a/core/lib/Drupal/Core/Language/LanguageManager.php
+++ b/core/lib/Drupal/Core/Language/LanguageManager.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Language;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\DependencyInjection\DependencySerializationTrait;
 use Drupal\Core\StringTranslation\TranslationInterface;
@@ -69,7 +70,7 @@ public function setTranslation(TranslationInterface $translation) {
    * @see \Drupal\Core\StringTranslation\TranslationInterface()
    */
   protected function t($string, array $args = array(), array $options = array()) {
-    return $this->translation ? $this->translation->translate($string, $args, $options) : String::format($string, $args);
+    return $this->translation ? $this->translation->translate($string, $args, $options) : SafeMarkup::format($string, $args);
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Logger/LogMessageParser.php b/core/lib/Drupal/Core/Logger/LogMessageParser.php
index ba99129..fd76c63 100644
--- a/core/lib/Drupal/Core/Logger/LogMessageParser.php
+++ b/core/lib/Drupal/Core/Logger/LogMessageParser.php
@@ -21,7 +21,7 @@ public function parseMessagePlaceholders(&$message, array &$context) {
     if (($start = strpos($message, '{')) !== FALSE && strpos($message, '}') > $start) {
       $has_psr3 = TRUE;
       // Transform PSR3 style messages containing placeholders to
-      // \Drupal\Component\Utility\String::format() style.
+      // \Drupal\Component\Utility\SafeMarkup::format() style.
       $message = preg_replace('/\{(.*)\}/U', '@$1', $message);
     }
     foreach ($context as $key => $variable) {
@@ -35,7 +35,7 @@ public function parseMessagePlaceholders(&$message, array &$context) {
         }
       }
       if (!empty($key) && ($key[0] === '@' || $key[0] === '%' || $key[0] === '!')) {
-        // The key is now in \Drupal\Component\Utility\String::format() style.
+        // The key is now in \Drupal\Component\Utility\SafeMarkup::format() style.
         $variables[$key] = $variable;
       }
     }
diff --git a/core/lib/Drupal/Core/Logger/LogMessageParserInterface.php b/core/lib/Drupal/Core/Logger/LogMessageParserInterface.php
index 545b039..26615a3 100644
--- a/core/lib/Drupal/Core/Logger/LogMessageParserInterface.php
+++ b/core/lib/Drupal/Core/Logger/LogMessageParserInterface.php
@@ -20,14 +20,14 @@
    *   - PSR3 format:
    *     @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#12-message
    *   - Drupal specific string placeholder format:
-   *     @see \Drupal\Component\Utility\String::format()
+   *     @see \Drupal\Component\Utility\SafeMarkup::format()
    *
-   * Values in PSR3 format will be transformed to String::format() format.
+   * Values in PSR3 format will be transformed to SafeMarkup::format() format.
    *
    * @param string $message
    *   The message that contains the placeholders.
    *   If the message is in PSR3 style, it will be transformed to
-   *   \Drupal\Component\Utility\String::format() style.
+   *   \Drupal\Component\Utility\SafeMarkup::format() style.
    * @param array $context
    *   An array that may or may not contain placeholder variables.
    *
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkBase.php b/core/lib/Drupal/Core/Menu/MenuLinkBase.php
index bc591f7..74b1913 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkBase.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkBase.php
@@ -8,6 +8,7 @@
 namespace Drupal\Core\Menu;
 
 use Drupal\Component\Plugin\Exception\PluginException;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Plugin\PluginBase;
 use Drupal\Core\Url;
@@ -176,7 +177,7 @@ public function getTranslateRoute() {
    * {@inheritdoc}
    */
   public function deleteLink() {
-    throw new PluginException(String::format('Menu link plugin with ID @id does not support deletion', array('@id' => $this->getPluginId())));
+    throw new PluginException(SafeMarkup::format('Menu link plugin with ID @id does not support deletion', array('@id' => $this->getPluginId())));
   }
 
 }
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkManager.php b/core/lib/Drupal/Core/Menu/MenuLinkManager.php
index 3647e07..224d1fb 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkManager.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkManager.php
@@ -10,6 +10,7 @@
 use Drupal\Component\Plugin\Exception\PluginException;
 use Drupal\Component\Plugin\Exception\PluginNotFoundException;
 use Drupal\Component\Utility\NestedArray;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator;
@@ -281,7 +282,7 @@ protected function deleteInstance(MenuLinkInterface $instance, $persist) {
       }
     }
     else {
-      throw new PluginException(String::format('Menu link plugin with ID @id does not support deletion', array('@id' => $id)));
+      throw new PluginException(SafeMarkup::format('Menu link plugin with ID @id does not support deletion', array('@id' => $id)));
     }
     $this->treeStorage->delete($id);
   }
@@ -349,7 +350,7 @@ public function loadLinksByRoute($route_name, array $route_parameters = array(),
    */
   public function addDefinition($id, array $definition) {
     if ($this->treeStorage->load($id) || $id === '') {
-      throw new PluginException(String::format('The ID @id already exists as a plugin definition or is not valid', array('@id' => $id)));
+      throw new PluginException(SafeMarkup::format('The ID @id already exists as a plugin definition or is not valid', array('@id' => $id)));
     }
     // Add defaults, so there is no requirement to specify everything.
     $this->processDefinition($definition, $id);
@@ -396,7 +397,7 @@ protected function resetInstance(MenuLinkInterface $instance) {
     $id = $instance->getPluginId();
 
     if (!$instance->isResettable()) {
-      throw new PluginException(String::format('Menu link %id is not resettable', array('%id' => $id)));
+      throw new PluginException(SafeMarkup::format('Menu link %id is not resettable', array('%id' => $id)));
     }
     // Get the original data from disk, reset the override and re-save the menu
     // tree for this link.
diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
index 5d1edb9..b340ded 100644
--- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
+++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
@@ -8,6 +8,7 @@
 namespace Drupal\Core\Menu;
 
 use Drupal\Component\Plugin\Exception\PluginException;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\UrlHelper;
 use Drupal\Core\Cache\Cache;
@@ -476,7 +477,7 @@ protected function setParents(array &$fields, $parent, array $original) {
         $limit = $this->maxDepth() - 1;
       }
       if ($parent['depth'] > $limit) {
-        throw new PluginException(String::format('The link with ID @id or its children exceeded the maximum depth of @depth', array('@id' => $fields['id'], '@depth' => $this->maxDepth())));
+        throw new PluginException(SafeMarkup::format('The link with ID @id or its children exceeded the maximum depth of @depth', array('@id' => $fields['id'], '@depth' => $this->maxDepth())));
       }
       $fields['depth'] = $parent['depth'] + 1;
       $i = 1;
@@ -637,7 +638,7 @@ public function loadByProperties(array $properties) {
     foreach ($properties as $name => $value) {
       if (!in_array($name, $this->definitionFields(), TRUE)) {
         $fields = implode(', ', $this->definitionFields());
-        throw new \InvalidArgumentException(String::format('An invalid property name, @name was specified. Allowed property names are: @fields.', array('@name' => $name, '@fields' => $fields)));
+        throw new \InvalidArgumentException(SafeMarkup::format('An invalid property name, @name was specified. Allowed property names are: @fields.', array('@name' => $name, '@fields' => $fields)));
       }
       $query->condition($name, $value);
     }
diff --git a/core/lib/Drupal/Core/Plugin/Context/Context.php b/core/lib/Drupal/Core/Plugin/Context/Context.php
index a0ad01f..39fedc6 100644
--- a/core/lib/Drupal/Core/Plugin/Context/Context.php
+++ b/core/lib/Drupal/Core/Plugin/Context/Context.php
@@ -42,7 +42,7 @@ public function getContextValue() {
       $definition = $this->getContextDefinition();
       if ($definition->isRequired()) {
         $type = $definition->getDataType();
-        throw new ContextException(String::format("The @type context is required and not present.", array('@type' => $type)));
+        throw new ContextException(SafeMarkup::format("The @type context is required and not present.", array('@type' => $type)));
       }
       return NULL;
     }
diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php b/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php
index 8063b2d..bb1ec07 100644
--- a/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php
+++ b/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Plugin\Context;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\TypedData\TypedDataTrait;
 
@@ -220,7 +221,7 @@ public function getDataDefinition() {
     }
 
     if (!$definition) {
-      throw new \Exception(String::format('The data type "@type" is invalid', array('@type' => $this->getDataType())));
+      throw new \Exception(SafeMarkup::format('The data type "@type" is invalid', array('@type' => $this->getDataType())));
     }
     $definition->setLabel($this->getLabel())
       ->setDescription($this->getDescription())
diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php
index a5f4aba..e48d579 100644
--- a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php
+++ b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php
@@ -8,6 +8,7 @@
 namespace Drupal\Core\Plugin\Context;
 
 use Drupal\Component\Plugin\Exception\ContextException;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Plugin\ContextAwarePluginInterface;
 
@@ -86,7 +87,7 @@ public function applyContextMapping(ContextAwarePluginInterface $plugin, $contex
 
     // If there are any mappings that were not satisfied, throw an exception.
     if (!empty($mappings)) {
-      throw new ContextException(String::format('Assigned contexts were not satisfied: @mappings', ['@mappings' => implode(',', array_keys($mappings))]));
+      throw new ContextException(SafeMarkup::format('Assigned contexts were not satisfied: @mappings', ['@mappings' => implode(',', array_keys($mappings))]));
     }
   }
 
diff --git a/core/lib/Drupal/Core/Render/Element.php b/core/lib/Drupal/Core/Render/Element.php
index eed5c30..73b0741 100644
--- a/core/lib/Drupal/Core/Render/Element.php
+++ b/core/lib/Drupal/Core/Render/Element.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Render;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -90,7 +91,7 @@ public static function children(array &$elements, $sort = FALSE) {
         // Only trigger an error if the value is not null.
         // @see http://drupal.org/node/1283892
         elseif (isset($value)) {
-          trigger_error(String::format('"@key" is an invalid render array key', array('@key' => $key)), E_USER_ERROR);
+          trigger_error(SafeMarkup::format('"@key" is an invalid render array key', array('@key' => $key)), E_USER_ERROR);
         }
       }
     }
diff --git a/core/lib/Drupal/Core/Routing/AcceptHeaderMatcher.php b/core/lib/Drupal/Core/Routing/AcceptHeaderMatcher.php
index 5c0618c..e83ae83 100644
--- a/core/lib/Drupal/Core/Routing/AcceptHeaderMatcher.php
+++ b/core/lib/Drupal/Core/Routing/AcceptHeaderMatcher.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Routing;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
@@ -61,7 +62,7 @@ public function filter(RouteCollection $collection, Request $request) {
     // We do not throw a
     // \Symfony\Component\Routing\Exception\ResourceNotFoundException here
     // because we don't want to return a 404 status code, but rather a 406.
-    throw new NotAcceptableHttpException(String::format('No route found for the specified formats @formats.', array('@formats' => implode(' ', $acceptable_mime_types))));
+    throw new NotAcceptableHttpException(SafeMarkup::format('No route found for the specified formats @formats.', array('@formats' => implode(' ', $acceptable_mime_types))));
   }
 
   /**
diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php
index bc560cf..6779a84 100644
--- a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php
+++ b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php
@@ -22,7 +22,7 @@
    * @param array $args
    *   An associative array of replacements to make after translation. Based
    *   on the first character of the key, the value is escaped and/or themed.
-   *   See \Drupal\Component\Utility\String::format() for details.
+   *   See \Drupal\Component\Utility\SafeMarkup::format() for details.
    * @param array $options
    *   An associative array of additional options, with the following elements:
    *   - 'langcode': The language code to translate to a language other than
@@ -32,7 +32,7 @@
    * @return string
    *   The translated string.
    *
-   * @see \Drupal\Component\Utility\String::format()
+   * @see \Drupal\Component\Utility\SafeMarkup::format()
    */
   public function translate($string, array $args = array(), array $options = array());
 
@@ -70,8 +70,9 @@ public function translate($string, array $args = array(), array $options = array
    *   An associative array of replacements to make after translation. Instances
    *   of any key in this array are replaced with the corresponding value.
    *   Based on the first character of the key, the value is escaped and/or
-   *   themed. See format_string(). Note that you do not need to include @count
-   *   in this array; this replacement is done automatically for the plural case.
+   *   themed. See \Drupal\Component\Utility\SafeMarkup::format(). Note that you do
+   *   not need to include @count in this array; this replacement is done
+   *   automatically for the plural case.
    * @param array $options
    *   An associative array of additional options. See t() for allowed keys.
    *
@@ -81,7 +82,7 @@ public function translate($string, array $args = array(), array $options = array
    * @see self::translate
    * @see \Drupal\Component\Utility\String
    * @see t()
-   * @see format_string()
+   * @see \Drupal\Component\Utility\SafeMarkup::format()
    */
   public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array());
 
diff --git a/core/lib/Drupal/Core/TypedData/ListDataDefinition.php b/core/lib/Drupal/Core/TypedData/ListDataDefinition.php
index b710a75..7cb522c 100644
--- a/core/lib/Drupal/Core/TypedData/ListDataDefinition.php
+++ b/core/lib/Drupal/Core/TypedData/ListDataDefinition.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\Core\TypedData;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * A typed data definition class for defining lists.
@@ -87,7 +88,7 @@ public function getClass() {
       $item_type_definition = \Drupal::typedDataManager()
         ->getDefinition($this->getItemDefinition()->getDataType());
       if (!$item_type_definition) {
-        throw new \LogicException(format_string('An invalid data type @plugin_id has been specified for list items.', array('@plugin_id' => $this->getItemDefinition()->getDataType())));
+        throw new \LogicException(SafeMarkup::format('An invalid data type @plugin_id has been specified for list items.', array('@plugin_id' => $this->getItemDefinition()->getDataType())));
       }
       return $item_type_definition['list_class'];
     }
diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php
index 18310bd..832f44d 100644
--- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php
+++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php
@@ -97,7 +97,7 @@ public function createInstance($data_type, array $configuration = array()) {
     $type_definition = $this->getDefinition($data_type);
 
     if (!isset($type_definition)) {
-      throw new \InvalidArgumentException(format_string('Invalid data type %plugin_id has been given.', array('%plugin_id' => $data_type)));
+      throw new \InvalidArgumentException(SafeMarkup::format('Invalid data type %plugin_id has been given.', array('%plugin_id' => $data_type)));
     }
 
     // Allow per-data definition overrides of the used classes, i.e. take over
@@ -177,7 +177,7 @@ public function create(DataDefinitionInterface $definition, $value = NULL, $name
   public function createDataDefinition($data_type) {
     $type_definition = $this->getDefinition($data_type);
     if (!isset($type_definition)) {
-      throw new \InvalidArgumentException(format_string('Invalid data type %plugin_id has been given.', array('%plugin_id' => $data_type)));
+      throw new \InvalidArgumentException(SafeMarkup::format('Invalid data type %plugin_id has been given.', array('%plugin_id' => $data_type)));
     }
     $class = $type_definition['definition_class'];
     return $class::createFromDataType($data_type);
@@ -197,7 +197,7 @@ public function createDataDefinition($data_type) {
   public function createListDataDefinition($item_type) {
     $type_definition = $this->getDefinition($item_type);
     if (!isset($type_definition)) {
-      throw new \InvalidArgumentException(format_string('Invalid data type %plugin_id has been given.', array('%plugin_id' => $item_type)));
+      throw new \InvalidArgumentException(SafeMarkup::format('Invalid data type %plugin_id has been given.', array('%plugin_id' => $item_type)));
     }
     $class = $type_definition['list_definition_class'];
     return $class::createFromItemType($item_type);
diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php
index 90d43c2..c6a5f05 100644
--- a/core/lib/Drupal/Core/Url.php
+++ b/core/lib/Drupal/Core/Url.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\Core;
 
-use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\UrlHelper;
 use Drupal\Core\DependencyInjection\DependencySerializationTrait;
 use Drupal\Core\Routing\RouteMatchInterface;
@@ -232,7 +232,7 @@ public static function fromUserInput($user_input, $options = []) {
     // because these are URI reserved characters that a scheme name may not
     // start with.
     if ((strpos($user_input, '/') !== 0) && (strpos($user_input, '#') !== 0) && (strpos($user_input, '?') !== 0)) {
-      throw new \InvalidArgumentException(String::format("The user-entered string @user_input must begin with a '/', '?', or '#'.", ['@user_input' => $user_input]));
+      throw new \InvalidArgumentException(SafeMarkup::format("The user-entered string @user_input must begin with a '/', '?', or '#'.", ['@user_input' => $user_input]));
     }
 
     // fromUri() requires an absolute URI, so prepend the appropriate scheme
@@ -296,10 +296,10 @@ public static function fromUserInput($user_input, $options = []) {
   public static function fromUri($uri, $options = []) {
     $uri_parts = parse_url($uri);
     if ($uri_parts === FALSE) {
-      throw new \InvalidArgumentException(String::format('The URI "@uri" is malformed.', ['@uri' => $uri]));
+      throw new \InvalidArgumentException(SafeMarkup::format('The URI "@uri" is malformed.', ['@uri' => $uri]));
     }
     if (empty($uri_parts['scheme'])) {
-      throw new \InvalidArgumentException(String::format('The URI "@uri" is invalid. You must use a valid URI scheme.', ['@uri' => $uri]));
+      throw new \InvalidArgumentException(SafeMarkup::format('The URI "@uri" is invalid. You must use a valid URI scheme.', ['@uri' => $uri]));
     }
     $uri_parts += ['path' => ''];
     // Discard empty fragment in $options for consistency with parse_url().
@@ -362,7 +362,7 @@ public static function fromUri($uri, $options = []) {
   protected static function fromEntityUri(array $uri_parts, array $options, $uri) {
     list($entity_type_id, $entity_id) = explode('/', $uri_parts['path'], 2);
     if ($uri_parts['scheme'] != 'entity' || $entity_id === '') {
-      throw new \InvalidArgumentException(String::format('The entity URI "@uri" is invalid. You must specify the entity id in the URL. e.g., entity:node/1 for loading the canonical path to node entity with id 1.', ['@uri' => $uri]));
+      throw new \InvalidArgumentException(SafeMarkup::format('The entity URI "@uri" is invalid. You must specify the entity id in the URL. e.g., entity:node/1 for loading the canonical path to node entity with id 1.', ['@uri' => $uri]));
     }
 
     return new static("entity.$entity_type_id.canonical", [$entity_type_id => $entity_id], $options);
@@ -422,7 +422,7 @@ protected static function fromInternalUri(array $uri_parts, array $options) {
     }
     else {
       if ($uri_parts['path'][0] !== '/') {
-        throw new \InvalidArgumentException(String::format('The internal path component "@path" is invalid. Its path component must have a leading slash, e.g. internal:/foo.', ['@path' => $uri_parts['path']]));
+        throw new \InvalidArgumentException(SafeMarkup::format('The internal path component "@path" is invalid. Its path component must have a leading slash, e.g. internal:/foo.', ['@path' => $uri_parts['path']]));
       }
       // Remove the leading slash.
       $uri_parts['path'] = substr($uri_parts['path'], 1);
@@ -458,7 +458,7 @@ protected static function fromRouteUri(array $uri_parts, array $options, $uri) {
     $route_parts = explode(';', $uri_parts['path'], 2);
     $route_name = $route_parts[0];
     if ($route_name === '') {
-      throw new \InvalidArgumentException(String::format('The route URI "@uri" is invalid. You must have a route name in the URI. e.g., route:system.admin', ['@uri' => $uri]));
+      throw new \InvalidArgumentException(SafeMarkup::format('The route URI "@uri" is invalid. You must have a route name in the URI. e.g., route:system.admin', ['@uri' => $uri]));
     }
     $route_parameters = [];
     if (!empty($route_parts[1])) {
diff --git a/core/lib/Drupal/Core/Utility/Error.php b/core/lib/Drupal/Core/Utility/Error.php
index 9fb001b..4ede922 100644
--- a/core/lib/Drupal/Core/Utility/Error.php
+++ b/core/lib/Drupal/Core/Utility/Error.php
@@ -96,7 +96,7 @@ public static function renderExceptionSafe(\Exception $exception) {
     // Remove 'main()'.
     array_shift($backtrace);
 
-    $output = String::format('%type: !message in %function (line %line of %file).', $decode);
+    $output = SafeMarkup::format('%type: !message in %function (line %line of %file).', $decode);
     // Even though it is possible that this method is called on a public-facing
     // site, it is only called when the exception handler itself threw an
     // exception, which normally means that a code change caused the system to
diff --git a/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php b/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php
index cb0e65a..8d2d9fc 100644
--- a/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php
+++ b/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php
@@ -41,7 +41,7 @@
    *   Strings will be sanitized automatically. If you need to output HTML in
    *   the link text, use a render array or an already sanitized string such as
    *   the output of \Drupal\Component\Utility\Xss::filter() or
-   *   \Drupal\Component\Utility\String::format().
+   *   \Drupal\Component\Utility\SafeMarkup::format().
    * @param \Drupal\Core\Url $url
    *   The URL object used for the link. Amongst its options, the following may
    *   be set to affect the generated link:
diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
index 2aed98e..c77771b 100644
--- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
+++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Utility;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\UrlHelper;
 use Drupal\Core\Config\ConfigFactoryInterface;
@@ -68,7 +69,7 @@ public function assemble($uri, array $options = []) {
       // UrlHelper::isExternal() only returns true for safe protocols.
       return $this->buildExternalUrl($uri, $options);
     }
-    throw new \InvalidArgumentException(String::format('The URI "@uri" is invalid. You must use a valid URI scheme. Use base: for a path, e.g., to a Drupal file that needs the base path. Do not use this for internal paths controlled by Drupal.', ['@uri' => $uri]));
+    throw new \InvalidArgumentException(SafeMarkup::format('The URI "@uri" is invalid. You must use a valid URI scheme. Use base: for a path, e.g., to a Drupal file that needs the base path. Do not use this for internal paths controlled by Drupal.', ['@uri' => $uri]));
   }
 
   /**
diff --git a/core/modules/action/src/Tests/BulkFormTest.php b/core/modules/action/src/Tests/BulkFormTest.php
index f92329c..043cd79 100644
--- a/core/modules/action/src/Tests/BulkFormTest.php
+++ b/core/modules/action/src/Tests/BulkFormTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\action\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 use Drupal\views\Views;
 
@@ -59,7 +60,7 @@ public function testBulkForm() {
     // Make sure a checkbox appears on all rows.
     $edit = array();
     for ($i = 0; $i < 10; $i++) {
-      $this->assertFieldById('edit-node-bulk-form-' . $i, NULL, format_string('The checkbox on row @row appears.', array('@row' => $i)));
+      $this->assertFieldById('edit-node-bulk-form-' . $i, NULL, SafeMarkup::format('The checkbox on row @row appears.', array('@row' => $i)));
       $edit["node_bulk_form[$i]"] = TRUE;
     }
 
@@ -77,7 +78,7 @@ public function testBulkForm() {
 
     foreach ($nodes as $node) {
       $changed_node = $node_storage->load($node->id());
-      $this->assertTrue($changed_node->isSticky(), format_string('Node @nid got marked as sticky.', array('@nid' => $node->id())));
+      $this->assertTrue($changed_node->isSticky(), SafeMarkup::format('Node @nid got marked as sticky.', array('@nid' => $node->id())));
     }
 
     $this->assertText('Make content sticky was applied to 10 items.');
diff --git a/core/modules/aggregator/src/Form/SettingsForm.php b/core/modules/aggregator/src/Form/SettingsForm.php
index 69c5ed6..2c9994e 100644
--- a/core/modules/aggregator/src/Form/SettingsForm.php
+++ b/core/modules/aggregator/src/Form/SettingsForm.php
@@ -8,6 +8,7 @@
 namespace Drupal\aggregator\Form;
 
 use Drupal\aggregator\Plugin\AggregatorPluginManager;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Form\FormStateInterface;
@@ -71,7 +72,7 @@ public function __construct(ConfigFactoryInterface $config_factory, AggregatorPl
     // Get all available fetcher, parser and processor definitions.
     foreach (array('fetcher', 'parser', 'processor') as $type) {
       foreach ($this->managers[$type]->getDefinitions() as $id => $definition) {
-        $this->definitions[$type][$id] = String::format('@title <span class="description">@description</span>', array('@title' => $definition['title'], '@description' => $definition['description']));
+        $this->definitions[$type][$id] = SafeMarkup::format('@title <span class="description">@description</span>', array('@title' => $definition['title'], '@description' => $definition['description']));
       }
     }
   }
diff --git a/core/modules/aggregator/src/Tests/AggregatorAdminTest.php b/core/modules/aggregator/src/Tests/AggregatorAdminTest.php
index edc594b..b0f7d1f 100644
--- a/core/modules/aggregator/src/Tests/AggregatorAdminTest.php
+++ b/core/modules/aggregator/src/Tests/AggregatorAdminTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\aggregator\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests aggregator admin pages.
@@ -40,7 +41,7 @@ public function testSettingsPage() {
     $this->assertText(t('The configuration options have been saved.'));
 
     foreach ($edit as $name => $value) {
-      $this->assertFieldByName($name, $value, format_string('"@name" has correct default value.', array('@name' => $name)));
+      $this->assertFieldByName($name, $value, SafeMarkup::format('"@name" has correct default value.', array('@name' => $name)));
     }
 
     // Check for our test processor settings form.
diff --git a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
index 024acfe..2946198 100644
--- a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
+++ b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\aggregator\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -55,7 +56,7 @@ public function testBlockLinks() {
     // Find the expected read_more link.
     $href = $feed->url();
     $links = $this->xpath('//a[@href = :href]', array(':href' => $href));
-    $this->assert(isset($links[0]), format_string('Link to href %href found.', array('%href' => $href)));
+    $this->assert(isset($links[0]), SafeMarkup::format('Link to href %href found.', array('%href' => $href)));
     $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
     $cache_tags = explode(' ', $cache_tags_header);
     $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
@@ -107,7 +108,7 @@ public function testFeedPage() {
     // Find the expected read_more link on the sources page.
     $href = $feed->url();
     $links = $this->xpath('//a[@href = :href]', array(':href' => $href));
-    $this->assertTrue(isset($links[0]), String::format('Link to href %href found.', array('%href' => $href)));
+    $this->assertTrue(isset($links[0]), SafeMarkup::format('Link to href %href found.', array('%href' => $href)));
     $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
     $cache_tags = explode(' ', $cache_tags_header);
     $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
diff --git a/core/modules/aggregator/src/Tests/AggregatorTestBase.php b/core/modules/aggregator/src/Tests/AggregatorTestBase.php
index 3c5a452..2f82ab0 100644
--- a/core/modules/aggregator/src/Tests/AggregatorTestBase.php
+++ b/core/modules/aggregator/src/Tests/AggregatorTestBase.php
@@ -8,6 +8,7 @@
 namespace Drupal\aggregator\Tests;
 
 use Drupal\aggregator\Entity\Feed;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 use Drupal\aggregator\FeedInterface;
 
@@ -64,7 +65,7 @@ protected function setUp() {
   public function createFeed($feed_url = NULL, array $edit = array()) {
     $edit = $this->getFeedEditArray($feed_url, $edit);
     $this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
-    $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed !name has been added.', array('!name' => $edit['title[0][value]'])));
+    $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), SafeMarkup::format('The feed !name has been added.', array('!name' => $edit['title[0][value]'])));
 
     $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']))->fetchField();
     $this->assertTrue(!empty($fid), 'The feed found in database.');
@@ -164,7 +165,7 @@ public function getDefaultFeedItemCount() {
   public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
     // First, let's ensure we can get to the rss xml.
     $this->drupalGet($feed->getUrl());
-    $this->assertResponse(200, format_string('!url is reachable.', array('!url' => $feed->getUrl())));
+    $this->assertResponse(200, SafeMarkup::format('!url is reachable.', array('!url' => $feed->getUrl())));
 
     // Attempt to access the update link directly without an access token.
     $this->drupalGet('admin/config/services/aggregator/update/' . $feed->id());
@@ -183,7 +184,7 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
 
     if ($expected_count !== NULL) {
       $feed->item_count = count($feed->items);
-      $this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (!val1 != !val2)', array('!val1' => $expected_count, '!val2' => $feed->item_count)));
+      $this->assertEqual($expected_count, $feed->item_count, SafeMarkup::format('Total items in feed equal to the total items in database (!val1 != !val2)', array('!val1' => $expected_count, '!val2' => $feed->item_count)));
     }
   }
 
diff --git a/core/modules/aggregator/src/Tests/FeedParserTest.php b/core/modules/aggregator/src/Tests/FeedParserTest.php
index 371b10f..b287981 100644
--- a/core/modules/aggregator/src/Tests/FeedParserTest.php
+++ b/core/modules/aggregator/src/Tests/FeedParserTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\aggregator\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Url;
 use Zend\Feed\Reader\Reader;
 
@@ -40,7 +41,7 @@ public function testRSS091Sample() {
     $feed = $this->createFeed($this->getRSS091Sample());
     $feed->refreshItems();
     $this->drupalGet('aggregator/sources/' . $feed->id());
-    $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label())));
+    $this->assertResponse(200, SafeMarkup::format('Feed %name exists.', array('%name' => $feed->label())));
     $this->assertText('First example feed item title');
     $this->assertLinkByHref('http://example.com/example-turns-one');
     $this->assertText('First example feed item description.');
@@ -63,7 +64,7 @@ public function testAtomSample() {
     $feed = $this->createFeed($this->getAtomSample());
     $feed->refreshItems();
     $this->drupalGet('aggregator/sources/' . $feed->id());
-    $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label())));
+    $this->assertResponse(200, SafeMarkup::format('Feed %name exists.', array('%name' => $feed->label())));
     $this->assertText('Atom-Powered Robots Run Amok');
     $this->assertLinkByHref('http://example.org/2003/12/13/atom03');
     $this->assertText('Some text.');
@@ -77,7 +78,7 @@ public function testHtmlEntitiesSample() {
     $feed = $this->createFeed($this->getHtmlEntitiesSample());
     $feed->refreshItems();
     $this->drupalGet('aggregator/sources/' . $feed->id());
-    $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label())));
+    $this->assertResponse(200, SafeMarkup::format('Feed %name exists.', array('%name' => $feed->label())));
     $this->assertRaw("Quote&quot; Amp&amp;");
   }
 
diff --git a/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php b/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php
index e100d64..a4c540c 100644
--- a/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php
+++ b/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\aggregator\Tests;
 use Drupal\aggregator\Entity\Feed;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Update feed items from a feed.
@@ -37,10 +38,10 @@ public function testUpdateFeedItem() {
     );
 
     $this->drupalGet($edit['url[0][value]']);
-    $this->assertResponse(array(200), format_string('URL !url is accessible', array('!url' => $edit['url[0][value]'])));
+    $this->assertResponse(array(200), SafeMarkup::format('URL !url is accessible', array('!url' => $edit['url[0][value]'])));
 
     $this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
-    $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed !name has been added.', array('!name' => $edit['title[0][value]'])));
+    $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), SafeMarkup::format('The feed !name has been added.', array('!name' => $edit['title[0][value]'])));
 
     $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE url = :url", array(':url' => $edit['url[0][value]']))->fetchField();
     $feed = Feed::load($fid);
@@ -62,7 +63,7 @@ public function testUpdateFeedItem() {
     $feed->refreshItems();
 
     $after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
-    $this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (!before === !after)', array('!before' => $before, '!after' => $after)));
+    $this->assertTrue($before === $after, SafeMarkup::format('Publish timestamp of feed item was not updated (!before === !after)', array('!before' => $before, '!after' => $after)));
 
     // Make sure updating items works even after uninstalling a module
     // that provides the selected plugins.
diff --git a/core/modules/aggregator/src/Tests/UpdateFeedTest.php b/core/modules/aggregator/src/Tests/UpdateFeedTest.php
index 71ca7de..f744db6 100644
--- a/core/modules/aggregator/src/Tests/UpdateFeedTest.php
+++ b/core/modules/aggregator/src/Tests/UpdateFeedTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\aggregator\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Update feed test.
@@ -29,7 +30,7 @@ public function testUpdateFeed() {
         $edit[$same_field] = $feed->{$same_field}->value;
       }
       $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, t('Save'));
-      $this->assertRaw(t('The feed %name has been updated.', array('%name' => $edit['title[0][value]'])), format_string('The feed %name has been updated.', array('%name' => $edit['title[0][value]'])));
+      $this->assertRaw(t('The feed %name has been updated.', array('%name' => $edit['title[0][value]'])), SafeMarkup::format('The feed %name has been updated.', array('%name' => $edit['title[0][value]'])));
 
       // Check feed data.
       $this->assertUrl($feed->url('canonical', ['absolute' => TRUE]));
diff --git a/core/modules/ban/src/BanMiddleware.php b/core/modules/ban/src/BanMiddleware.php
index ca4f1d7..e15c2ee 100644
--- a/core/modules/ban/src/BanMiddleware.php
+++ b/core/modules/ban/src/BanMiddleware.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\ban;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
@@ -50,7 +51,7 @@ public function __construct(HttpKernelInterface $http_kernel, BanIpManagerInterf
   public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
     $ip = $request->getClientIp();
     if ($this->banIpManager->isBanned($ip)) {
-      return new Response(String::format('Sorry @ip has been banned', ['@ip' => $ip]), 403);
+      return new Response(SafeMarkup::format('Sorry @ip has been banned', ['@ip' => $ip]), 403);
     }
     return $this->httpKernel->handle($request, $type, $catch);
   }
diff --git a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
index c2b8483..622cc80 100644
--- a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
+++ b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\basic_auth\Authentication\Provider;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Authentication\AuthenticationProviderInterface;
 use Drupal\Core\Authentication\AuthenticationProviderChallengeInterface;
@@ -132,7 +133,7 @@ public function authenticate(Request $request) {
    */
   public function challengeException(Request $request, \Exception $previous) {
     $site_name = $this->configFactory->get('system.site')->get('name');
-    $challenge = String::format('Basic realm="@realm"', array(
+    $challenge = SafeMarkup::format('Basic realm="@realm"', array(
       '@realm' => !empty($site_name) ? $site_name : 'Access restricted',
     ));
     return new UnauthorizedHttpException($challenge, 'No authentication credentials provided.', $previous);
diff --git a/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php b/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php
index 44c14f1..d838b2e 100644
--- a/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php
+++ b/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\basic_auth\Tests\Authentication;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Url;
 use Drupal\language\Entity\ConfigurableLanguage;
@@ -54,7 +55,7 @@ public function testBasicAuth() {
     // @todo Change ->drupalGet() calls to just pass $url when
     //   https://www.drupal.org/node/2350837 gets committed
     $this->drupalGet($url->setAbsolute()->toString());
-    $this->assertEqual($this->drupalGetHeader('WWW-Authenticate'), String::format('Basic realm="@realm"', ['@realm' => \Drupal::config('system.site')->get('name')]));
+    $this->assertEqual($this->drupalGetHeader('WWW-Authenticate'), SafeMarkup::format('Basic realm="@realm"', ['@realm' => \Drupal::config('system.site')->get('name')]));
     $this->assertResponse('401', 'Not authenticated on the route that allows only basic_auth. Prompt to authenticate received.');
 
     $this->drupalGet('admin');
diff --git a/core/modules/block/src/BlockPluginCollection.php b/core/modules/block/src/BlockPluginCollection.php
index 0f103ca..a24f9c8 100644
--- a/core/modules/block/src/BlockPluginCollection.php
+++ b/core/modules/block/src/BlockPluginCollection.php
@@ -56,7 +56,7 @@ public function &get($instance_id) {
    */
   protected function initializePlugin($instance_id) {
     if (!$instance_id) {
-      throw new PluginException(String::format("The block '@block' did not specify a plugin.", array('@block' => $this->blockId)));
+      throw new PluginException(SafeMarkup::format("The block '@block' did not specify a plugin.", array('@block' => $this->blockId)));
     }
 
     try {
diff --git a/core/modules/block/src/Tests/BlockTest.php b/core/modules/block/src/Tests/BlockTest.php
index 7053696..9903206 100644
--- a/core/modules/block/src/Tests/BlockTest.php
+++ b/core/modules/block/src/Tests/BlockTest.php
@@ -288,7 +288,7 @@ function moveBlockToRegion(array $block, $region) {
     $this->drupalPostForm('admin/structure/block', $edit, t('Save blocks'));
 
     // Confirm that the block was moved to the proper region.
-    $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', array( '%region_name' => $region)));
+    $this->assertText(t('The block settings have been updated.'), SafeMarkup::format('Block successfully moved to %region_name region.', array( '%region_name' => $region)));
 
     // Confirm that the block is being displayed.
     $this->drupalGet('');
diff --git a/core/modules/block/src/Tests/Views/DisplayBlockTest.php b/core/modules/block/src/Tests/Views/DisplayBlockTest.php
index 9e6c8c3..e52bd52 100644
--- a/core/modules/block/src/Tests/Views/DisplayBlockTest.php
+++ b/core/modules/block/src/Tests/Views/DisplayBlockTest.php
@@ -279,8 +279,8 @@ public function testBlockContextualLinks() {
     $id = 'block:block=' . $block->id() . ':|entity.view.edit_form:view=test_view_block:location=block&name=test_view_block&display_id=block_1';
     $cached_id = 'block:block=' . $cached_block->id() . ':|entity.view.edit_form:view=test_view_block:location=block&name=test_view_block&display_id=block_1';
     // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
-    $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
-    $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $cached_id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $cached_id)));
+    $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', SafeMarkup::format('Contextual link placeholder with id @id exists.', array('@id' => $id)));
+    $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $cached_id)) . '></div>', SafeMarkup::format('Contextual link placeholder with id @id exists.', array('@id' => $cached_id)));
 
     // Get server-rendered contextual links.
     // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
diff --git a/core/modules/block_content/src/Tests/BlockContentCreationTest.php b/core/modules/block_content/src/Tests/BlockContentCreationTest.php
index 6bf250c..8e487f7 100644
--- a/core/modules/block_content/src/Tests/BlockContentCreationTest.php
+++ b/core/modules/block_content/src/Tests/BlockContentCreationTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\block_content\Tests;
 
 use Drupal\block_content\Entity\BlockContent;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Database\Database;
 
@@ -48,7 +49,7 @@ public function testBlockContentCreation() {
     $this->drupalPostForm('block/add/basic', $edit, t('Save'));
 
     // Check that the Basic block has been created.
-    $this->assertRaw(format_string('!block %name has been created.', array(
+    $this->assertRaw(SafeMarkup::format('!block %name has been created.', array(
       '!block' => 'basic',
       '%name' => $edit['info[0][value]']
     )), 'Basic block created.');
@@ -66,7 +67,7 @@ public function testBlockContentCreation() {
     $this->drupalPostForm('block/add/basic', $edit, t('Save'));
 
     // Check that the Basic block has been created.
-    $this->assertRaw(format_string('A block with description %name already exists.', array(
+    $this->assertRaw(SafeMarkup::format('A block with description %name already exists.', array(
       '%name' => $edit['info[0][value]']
     )));
     $this->assertResponse(200);
@@ -95,7 +96,7 @@ public function testBlockContentCreationMultipleViewModes() {
     $this->drupalPostForm('block/add/basic', $edit, t('Save'));
 
     // Check that the Basic block has been created.
-    $this->assertRaw(format_string('!block %name has been created.', array(
+    $this->assertRaw(SafeMarkup::format('!block %name has been created.', array(
       '!block' => 'basic',
       '%name' => $edit['info[0][value]']
     )), 'Basic block created.');
@@ -124,7 +125,7 @@ public function testBlockContentCreationMultipleViewModes() {
     $this->drupalPostForm('block/add/basic', $edit, t('Save'));
 
     // Check that the Basic block has been created.
-    $this->assertRaw(format_string('A block with description %name already exists.', array(
+    $this->assertRaw(SafeMarkup::format('A block with description %name already exists.', array(
       '%name' => $edit['info[0][value]']
     )));
     $this->assertResponse(200);
@@ -144,7 +145,7 @@ public function testDefaultBlockContentCreation() {
     $this->drupalPostForm('block/add', $edit, t('Save'));
 
     // Check that the block has been created and that it is a basic block.
-    $this->assertRaw(format_string('!block %name has been created.', array(
+    $this->assertRaw(SafeMarkup::format('!block %name has been created.', array(
       '!block' => 'basic',
       '%name' => $edit['info[0][value]'],
     )), 'Basic block created.');
diff --git a/core/modules/block_content/src/Tests/BlockContentRevisionsTest.php b/core/modules/block_content/src/Tests/BlockContentRevisionsTest.php
index 8da9c54..a5750bd 100644
--- a/core/modules/block_content/src/Tests/BlockContentRevisionsTest.php
+++ b/core/modules/block_content/src/Tests/BlockContentRevisionsTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\block_content\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 
 use Drupal\block_content\Entity\BlockContent;
 
@@ -69,7 +70,7 @@ public function testRevisions() {
       // Confirm the correct revision text appears.
       $loaded = entity_revision_load('block_content', $revision_id);
       // Verify revision log is the same.
-      $this->assertEqual($loaded->getRevisionLog(), $logs[$delta], format_string('Correct log message found for revision !revision', array(
+      $this->assertEqual($loaded->getRevisionLog(), $logs[$delta], SafeMarkup::format('Correct log message found for revision !revision', array(
         '!revision' => $loaded->getRevisionId(),
       )));
     }
diff --git a/core/modules/block_content/src/Tests/PageEditTest.php b/core/modules/block_content/src/Tests/PageEditTest.php
index fdd1743..6c3498a 100644
--- a/core/modules/block_content/src/Tests/PageEditTest.php
+++ b/core/modules/block_content/src/Tests/PageEditTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\block_content\Tests;
 
 use Drupal\block_content\Entity\BlockContent;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 
 /**
@@ -64,7 +65,7 @@ public function testPageEdit() {
     // Test deleting the block.
     $this->drupalGet("block/" . $revised_block->id());
     $this->clickLink(t('Delete'));
-    $this->assertText(format_string('Are you sure you want to delete the custom block !label?', array('!label' => $revised_block->label())));
+    $this->assertText(SafeMarkup::format('Are you sure you want to delete the custom block !label?', array('!label' => $revised_block->label())));
   }
 
 }
diff --git a/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php b/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php
index 83dc590..156bcfa 100644
--- a/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php
+++ b/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php
@@ -8,6 +8,7 @@
 namespace Drupal\block_content\Tests\Views;
 
 use Drupal\block_content\Entity\BlockContentType;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\views\Tests\ViewTestBase;
 use Drupal\views\Tests\ViewTestData;
@@ -72,7 +73,7 @@ protected function createBlockContent(array $settings = array()) {
     if ($block_content = entity_create('block_content', $settings)) {
       $status = $block_content->save();
     }
-    $this->assertEqual($status, SAVED_NEW, String::format('Created block content %info.', array('%info' => $block_content->label())));
+    $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content %info.', array('%info' => $block_content->label())));
     return $block_content;
   }
 
@@ -104,7 +105,7 @@ protected function createBlockContentType(array $values = array()) {
     $status = $bundle->save();
     block_content_add_body_field($bundle->id());
 
-    $this->assertEqual($status, SAVED_NEW, String::format('Created block content type %bundle.', array('%bundle' => $bundle->id())));
+    $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content type %bundle.', array('%bundle' => $bundle->id())));
     return $bundle;
   }
 
diff --git a/core/modules/book/src/Tests/BookTest.php b/core/modules/book/src/Tests/BookTest.php
index 1102e69..d3c4d5e 100644
--- a/core/modules/book/src/Tests/BookTest.php
+++ b/core/modules/book/src/Tests/BookTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\book\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\simpletest\WebTestBase;
@@ -216,10 +217,10 @@ function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = F
 
     // Check outline structure.
     if ($nodes !== NULL) {
-      $this->assertPattern($this->generateOutlinePattern($nodes), format_string('Node @number outline confirmed.', array('@number' => $number)));
+      $this->assertPattern($this->generateOutlinePattern($nodes), SafeMarkup::format('Node @number outline confirmed.', array('@number' => $number)));
     }
     else {
-      $this->pass(format_string('Node %number does not have outline.', array('%number' => $number)));
+      $this->pass(SafeMarkup::format('Node %number does not have outline.', array('%number' => $number)));
     }
 
     // Check previous, up, and next links.
@@ -227,7 +228,7 @@ function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = F
       /** @var \Drupal\Core\Url $url */
       $url = $previous->urlInfo();
       $url->setOptions(array('attributes' => array('rel' => array('prev'), 'title' => t('Go to previous page'))));
-      $text = String::format('<b>‹</b> @label', array('@label' => $previous->label()));
+      $text = SafeMarkup::format('<b>‹</b> @label', array('@label' => $previous->label()));
       $this->assertRaw(\Drupal::l($text, $url), 'Previous page link found.');
     }
 
@@ -242,7 +243,7 @@ function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = F
       /** @var \Drupal\Core\Url $url */
       $url = $next->urlInfo();
       $url->setOptions(array('attributes' => array('rel' => array('next'), 'title' => t('Go to next page'))));
-      $text = String::format('@label <b>›</b>', array('@label' => $next->label()));
+      $text = SafeMarkup::format('@label <b>›</b>', array('@label' => $next->label()));
       $this->assertRaw(\Drupal::l($text, $url), 'Next page link found.');
     }
 
@@ -392,7 +393,7 @@ function testBookNavigationBlock() {
     $nodes = $this->createBook();
     $this->drupalGet('<front>');
     $this->assertText($block->label(), 'Book navigation block is displayed.');
-    $this->assertText($this->book->label(), format_string('Link to book root (@title) is displayed.', array('@title' => $nodes[0]->label())));
+    $this->assertText($this->book->label(), SafeMarkup::format('Link to book root (@title) is displayed.', array('@title' => $nodes[0]->label())));
     $this->assertNoText($nodes[0]->label(), 'No links to individual book pages are displayed.');
   }
 
diff --git a/core/modules/comment/src/Tests/CommentBlockTest.php b/core/modules/comment/src/Tests/CommentBlockTest.php
index f67c377..8e3a658 100644
--- a/core/modules/comment/src/Tests/CommentBlockTest.php
+++ b/core/modules/comment/src/Tests/CommentBlockTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\comment\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\user\RoleInterface;
 
@@ -72,11 +73,11 @@ function testRecentCommentBlock() {
     // Test the only the 10 latest comments are shown and in the proper order.
     $this->assertNoText($comments[10]->getSubject(), 'Comment 11 not found in block.');
     for ($i = 0; $i < 10; $i++) {
-      $this->assertText($comments[$i]->getSubject(), String::format('Comment @number found in block.', array('@number' => 10 - $i)));
+      $this->assertText($comments[$i]->getSubject(), SafeMarkup::format('Comment @number found in block.', array('@number' => 10 - $i)));
       if ($i > 1) {
         $previous_position = $position;
         $position = strpos($this->getRawContent(), $comments[$i]->getSubject());
-        $this->assertTrue($position > $previous_position, String::format('Comment @a appears after comment @b', array('@a' => 10 - $i, '@b' => 11 - $i)));
+        $this->assertTrue($position > $previous_position, SafeMarkup::format('Comment @a appears after comment @b', array('@a' => 10 - $i, '@b' => 11 - $i)));
       }
       $position = strpos($this->getRawContent(), $comments[$i]->getSubject());
     }
diff --git a/core/modules/comment/src/Tests/CommentFieldAccessTest.php b/core/modules/comment/src/Tests/CommentFieldAccessTest.php
index 7faecad..05632a3 100644
--- a/core/modules/comment/src/Tests/CommentFieldAccessTest.php
+++ b/core/modules/comment/src/Tests/CommentFieldAccessTest.php
@@ -8,6 +8,7 @@
 
 use Drupal\comment\Entity\Comment;
 use Drupal\comment\Entity\CommentType;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Session\AnonymousUserSession;
 use Drupal\entity_test\Entity\EntityTest;
@@ -205,13 +206,13 @@ public function testAccessToAdministrativeFields() {
       foreach ($permutations as $set) {
         $may_view = $set['comment']->{$field}->access('view', $set['user']);
         $may_update = $set['comment']->{$field}->access('edit', $set['user']);
-        $this->assertEqual($may_view, $set['user']->hasPermission('administer comments') || ($set['comment']->isPublished() && $set['user']->hasPermission('access comments')), String::format('User @user !state view field !field on comment @comment', [
+        $this->assertEqual($may_view, $set['user']->hasPermission('administer comments') || ($set['comment']->isPublished() && $set['user']->hasPermission('access comments')), SafeMarkup::format('User @user !state view field !field on comment @comment', [
           '@user' => $set['user']->getUsername(),
           '!state' => $may_update ? 'can' : 'cannot',
           '@comment' => $set['comment']->getSubject(),
           '!field' => $field,
         ]));
-        $this->assertEqual($may_update, $set['user']->hasPermission('administer comments'), String::format('User @user !state update field !field on comment @comment', [
+        $this->assertEqual($may_update, $set['user']->hasPermission('administer comments'), SafeMarkup::format('User @user !state update field !field on comment @comment', [
           '@user' => $set['user']->getUsername(),
           '!state' => $may_update ? 'can' : 'cannot',
           '@comment' => $set['comment']->getSubject(),
@@ -223,7 +224,7 @@ public function testAccessToAdministrativeFields() {
     // Check access to normal field.
     foreach ($permutations as $set) {
       $may_update = $set['comment']->access('update', $set['user']) && $set['comment']->subject->access('edit', $set['user']);
-      $this->assertEqual($may_update, $set['user']->hasPermission('administer comments') || ($set['user']->hasPermission('edit own comments') && $set['user']->id() == $set['comment']->getOwnerId()), String::format('User @user !state update field subject on comment @comment', [
+      $this->assertEqual($may_update, $set['user']->hasPermission('administer comments') || ($set['user']->hasPermission('edit own comments') && $set['user']->id() == $set['comment']->getOwnerId()), SafeMarkup::format('User @user !state update field subject on comment @comment', [
         '@user' => $set['user']->getUsername(),
         '!state' => $may_update ? 'can' : 'cannot',
         '@comment' => $set['comment']->getSubject(),
@@ -237,13 +238,13 @@ public function testAccessToAdministrativeFields() {
         $may_view = $set['comment']->{$field}->access('view', $set['user']);
         $may_update = $set['comment']->{$field}->access('edit', $set['user']);
         $this->assertEqual($may_view, $field != 'hostname' && ($set['user']->hasPermission('administer comments') ||
-            ($set['comment']->isPublished() && $set['user']->hasPermission('access comments'))), String::format('User @user !state view field !field on comment @comment', [
+            ($set['comment']->isPublished() && $set['user']->hasPermission('access comments'))), SafeMarkup::format('User @user !state view field !field on comment @comment', [
           '@user' => $set['user']->getUsername(),
           '!state' => $may_view ? 'can' : 'cannot',
           '@comment' => $set['comment']->getSubject(),
           '!field' => $field,
         ]));
-        $this->assertFalse($may_update, String::format('User @user !state update field !field on comment @comment', [
+        $this->assertFalse($may_update, SafeMarkup::format('User @user !state update field !field on comment @comment', [
           '@user' => $set['user']->getUsername(),
           '!state' => $may_update ? 'can' : 'cannot',
           '@comment' => $set['comment']->getSubject(),
@@ -265,7 +266,7 @@ public function testAccessToAdministrativeFields() {
             $set['comment']->isNew() &&
             $set['user']->hasPermission('post comments') &&
             $set['comment']->getFieldName() == 'comment_other'
-          ), String::format('User @user !state update field !field on comment @comment', [
+          ), SafeMarkup::format('User @user !state update field !field on comment @comment', [
           '@user' => $set['user']->getUsername(),
           '!state' => $may_update ? 'can' : 'cannot',
           '@comment' => $set['comment']->getSubject(),
diff --git a/core/modules/comment/src/Tests/CommentFieldsTest.php b/core/modules/comment/src/Tests/CommentFieldsTest.php
index 3ce7da6..3c3afc2 100644
--- a/core/modules/comment/src/Tests/CommentFieldsTest.php
+++ b/core/modules/comment/src/Tests/CommentFieldsTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\comment\Tests;
 
 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\comment\Entity\CommentType;
@@ -56,7 +57,7 @@ function testCommentDefaultFields() {
     $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body');
     $this->assertTrue($field_storage, 'The comment_body field exists');
     $field = FieldConfig::loadByName('comment', 'comment', 'comment_body');
-    $this->assertTrue(isset($field), format_string('The comment_body field is present for comments on type @type', array('@type' => $type_name)));
+    $this->assertTrue(isset($field), SafeMarkup::format('The comment_body field is present for comments on type @type', array('@type' => $type_name)));
 
     // Test adding a field that defaults to CommentItemInterface::CLOSED.
     $this->addDefaultCommentField('node', 'test_node_type', 'who_likes_ponies', CommentItemInterface::CLOSED, 'who_likes_ponies');
diff --git a/core/modules/comment/src/Tests/CommentLanguageTest.php b/core/modules/comment/src/Tests/CommentLanguageTest.php
index 883eb17..c58d4f7 100644
--- a/core/modules/comment/src/Tests/CommentLanguageTest.php
+++ b/core/modules/comment/src/Tests/CommentLanguageTest.php
@@ -9,6 +9,7 @@
 
 use Drupal\comment\Entity\Comment;
 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\simpletest\WebTestBase;
 
@@ -123,7 +124,7 @@ function testCommentLanguage() {
           ->execute();
         $comment = Comment::load(reset($cids));
         $args = array('%node_language' => $node_langcode, '%comment_language' => $comment->langcode->value, '%langcode' => $langcode);
-        $this->assertEqual($comment->langcode->value, $langcode, format_string('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
+        $this->assertEqual($comment->langcode->value, $langcode, SafeMarkup::format('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
         $this->assertEqual($comment->comment_body->value, $comment_values[$node_langcode][$langcode], 'Comment body correctly stored.');
       }
     }
diff --git a/core/modules/comment/src/Tests/CommentNonNodeTest.php b/core/modules/comment/src/Tests/CommentNonNodeTest.php
index 167381b..e500de5 100644
--- a/core/modules/comment/src/Tests/CommentNonNodeTest.php
+++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php
@@ -10,6 +10,7 @@
 use Drupal\comment\CommentInterface;
 use Drupal\comment\Entity\CommentType;
 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\field_ui\Tests\FieldUiTestTrait;
@@ -222,10 +223,10 @@ function performCommentOperation($comment, $operation, $approval = FALSE) {
 
     if ($operation == 'delete') {
       $this->drupalPostForm(NULL, array(), t('Delete comments'));
-      $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
+      $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), SafeMarkup::format('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
     }
     else {
-      $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
+      $this->assertText(t('The update has been performed.'), SafeMarkup::format('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
     }
   }
 
diff --git a/core/modules/comment/src/Tests/CommentPagerTest.php b/core/modules/comment/src/Tests/CommentPagerTest.php
index ca1c5a6..2d9c1cc 100644
--- a/core/modules/comment/src/Tests/CommentPagerTest.php
+++ b/core/modules/comment/src/Tests/CommentPagerTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\comment\Tests;
 
 use Drupal\comment\CommentManagerInterface;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\node\Entity\Node;
 
@@ -191,7 +192,7 @@ function assertCommentOrder(array $comments, array $expected_order) {
     foreach ($comment_anchors as $anchor) {
       $result_order[] = substr($anchor['id'], 8);
     }
-    return $this->assertEqual($expected_cids, $result_order, format_string('Comment order: expected @expected, returned @returned.', array('@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order))));
+    return $this->assertEqual($expected_cids, $result_order, SafeMarkup::format('Comment order: expected @expected, returned @returned.', array('@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order))));
   }
 
   /**
@@ -251,7 +252,7 @@ function testCommentNewPageIndicator() {
     foreach ($expected_pages as $new_replies => $expected_page) {
       $returned_page = \Drupal::entityManager()->getStorage('comment')
         ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node);
-      $this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
+      $this->assertIdentical($expected_page, $returned_page, SafeMarkup::format('Flat mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
     }
 
     $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Switched to threaded mode.');
@@ -270,7 +271,7 @@ function testCommentNewPageIndicator() {
     foreach ($expected_pages as $new_replies => $expected_page) {
       $returned_page = \Drupal::entityManager()->getStorage('comment')
         ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node);
-      $this->assertEqual($expected_page, $returned_page, format_string('Threaded mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
+      $this->assertEqual($expected_page, $returned_page, SafeMarkup::format('Threaded mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
     }
   }
 
@@ -378,10 +379,10 @@ protected function clickLinkWithXPath($xpath, $index = 0) {
     $urls = $this->xpath($xpath);
     if (isset($urls[$index])) {
       $url_target = $this->getAbsoluteUrl($urls[$index]['href']);
-      $this->pass(String::format('Clicked link %label (@url_target) from @url_before', array('%label' => $xpath, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser');
+      $this->pass(SafeMarkup::format('Clicked link %label (@url_target) from @url_before', array('%label' => $xpath, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser');
       return $this->drupalGet($url_target);
     }
-    $this->fail(String::format('Link %label does not exist on @url_before', array('%label' => $xpath, '@url_before' => $url_before)), 'Browser');
+    $this->fail(SafeMarkup::format('Link %label does not exist on @url_before', array('%label' => $xpath, '@url_before' => $url_before)), 'Browser');
     return FALSE;
   }
 
diff --git a/core/modules/comment/src/Tests/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php
index 12d17c6..769a4bd 100644
--- a/core/modules/comment/src/Tests/CommentTestBase.php
+++ b/core/modules/comment/src/Tests/CommentTestBase.php
@@ -10,6 +10,7 @@
 use Drupal\comment\Entity\CommentType;
 use Drupal\comment\Entity\Comment;
 use Drupal\comment\CommentInterface;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
 use Drupal\node\Entity\NodeType;
@@ -256,7 +257,7 @@ public function setCommentPreview($mode, $field_name = 'comment') {
         $mode_text = 'required';
         break;
     }
-    $this->setCommentSettings('preview', $mode, format_string('Comment preview @mode_text.', array('@mode_text' => $mode_text)), $field_name);
+    $this->setCommentSettings('preview', $mode, SafeMarkup::format('Comment preview @mode_text.', array('@mode_text' => $mode_text)), $field_name);
   }
 
   /**
@@ -283,7 +284,7 @@ public function setCommentForm($enabled, $field_name = 'comment') {
    *   - 2: Contact information required.
    */
   function setCommentAnonymous($level) {
-    $this->setCommentSettings('anonymous', $level, format_string('Anonymous commenting set to level @level.', array('@level' => $level)));
+    $this->setCommentSettings('anonymous', $level, SafeMarkup::format('Anonymous commenting set to level @level.', array('@level' => $level)));
   }
 
   /**
@@ -296,7 +297,7 @@ function setCommentAnonymous($level) {
    *   Defaults to 'comment'.
    */
   public function setCommentsPerPage($number, $field_name = 'comment') {
-    $this->setCommentSettings('per_page', $number, format_string('Number of comments per page set to @number.', array('@number' => $number)), $field_name);
+    $this->setCommentSettings('per_page', $number, SafeMarkup::format('Number of comments per page set to @number.', array('@number' => $number)), $field_name);
   }
 
   /**
@@ -348,10 +349,10 @@ function performCommentOperation(CommentInterface $comment, $operation, $approva
 
     if ($operation == 'delete') {
       $this->drupalPostForm(NULL, array(), t('Delete comments'));
-      $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
+      $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), SafeMarkup::format('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
     }
     else {
-      $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
+      $this->assertText(t('The update has been performed.'), SafeMarkup::format('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
     }
   }
 
diff --git a/core/modules/comment/src/Tests/CommentTestTrait.php b/core/modules/comment/src/Tests/CommentTestTrait.php
index bca6d5d..5cf8e8d 100644
--- a/core/modules/comment/src/Tests/CommentTestTrait.php
+++ b/core/modules/comment/src/Tests/CommentTestTrait.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\comment\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Unicode;
 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
@@ -42,7 +43,7 @@ public function addDefaultCommentField($entity_type, $bundle, $field_name = 'com
     $comment_type_storage = $entity_manager->getStorage('comment_type');
     if ($comment_type = $comment_type_storage->load($comment_type_id)) {
       if ($comment_type->getTargetEntityTypeId() !== $entity_type) {
-        throw new \InvalidArgumentException(String::format('The given comment type id %id can only be used with the %entity_type entity type', array(
+        throw new \InvalidArgumentException(SafeMarkup::format('The given comment type id %id can only be used with the %entity_type entity type', array(
           '%id' => $comment_type_id,
           '%entity_type' => $entity_type,
         )));
diff --git a/core/modules/comment/src/Tests/CommentThreadingTest.php b/core/modules/comment/src/Tests/CommentThreadingTest.php
index ab0d9b9..f2ec54b 100644
--- a/core/modules/comment/src/Tests/CommentThreadingTest.php
+++ b/core/modules/comment/src/Tests/CommentThreadingTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\comment\Tests;
 
 use Drupal\comment\CommentManagerInterface;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests to make sure the comment number increments properly.
@@ -142,7 +143,7 @@ protected function assertParentLink($cid, $pid) {
     //  </article>
     $pattern = "//a[@id='comment-$cid']/following-sibling::article//p[contains(@class, 'parent')]//a[contains(@href, 'comment-$pid')]";
 
-    $this->assertFieldByXpath($pattern, NULL, format_string(
+    $this->assertFieldByXpath($pattern, NULL, SafeMarkup::format(
       'Comment %cid has a link to parent %pid.',
       array(
         '%cid' => $cid,
@@ -165,7 +166,7 @@ protected function assertNoParentLink($cid) {
     //  </article>
 
     $pattern = "//a[@id='comment-$cid']/following-sibling::article//p[contains(@class, 'parent')]";
-    $this->assertNoFieldByXpath($pattern, NULL, format_string(
+    $this->assertNoFieldByXpath($pattern, NULL, SafeMarkup::format(
       'Comment %cid does not have a link to a parent.',
       array(
         '%cid' => $cid,
diff --git a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php
index 64cc9c3..b2ba7b6 100644
--- a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php
+++ b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php
@@ -76,7 +76,7 @@ function testCommentTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId()));
-      $this->assertEqual($output, $expected, format_string('Sanitized comment token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Sanitized comment token %token replaced.', array('%token' => $input)));
     }
 
     // Generate and test unsanitized tokens.
@@ -93,7 +93,7 @@ function testCommentTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE));
-      $this->assertEqual($output, $expected, format_string('Unsanitized comment token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Unsanitized comment token %token replaced.', array('%token' => $input)));
     }
 
     // Test anonymous comment author.
@@ -101,9 +101,9 @@ function testCommentTokenReplacement() {
     $comment->setOwnerId(0)->setAuthorName($author_name);
     $input = '[comment:author]';
     $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId()));
-    $this->assertEqual($output, Xss::filter($author_name), format_string('Sanitized comment author token %token replaced.', array('%token' => $input)));
+    $this->assertEqual($output, Xss::filter($author_name), SafeMarkup::format('Sanitized comment author token %token replaced.', array('%token' => $input)));
     $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE));
-    $this->assertEqual($output, $author_name, format_string('Unsanitized comment author token %token replaced.', array('%token' => $input)));
+    $this->assertEqual($output, $author_name, SafeMarkup::format('Unsanitized comment author token %token replaced.', array('%token' => $input)));
 
     // Load node so comment_count gets computed.
     $node = Node::load($node->id());
@@ -115,7 +115,7 @@ function testCommentTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('entity' => $node, 'node' => $node), array('langcode' => $language_interface->getId()));
-      $this->assertEqual($output, $expected, format_string('Node comment token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Node comment token %token replaced.', array('%token' => $input)));
     }
   }
 
diff --git a/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php b/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php
index 2b0f557..2566b5a 100644
--- a/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php
+++ b/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php
@@ -9,6 +9,7 @@
 
 use Drupal\comment\CommentInterface;
 use Drupal\comment\Tests\CommentTestTrait;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Views;
 use Drupal\views\Tests\ViewTestBase;
 
@@ -134,7 +135,7 @@ public function testBlockDisplay() {
 
     // Check the number of results given by the display is the expected.
     $this->assertEqual(sizeof($view->result), $this->blockDisplayResults,
-      format_string('There are exactly @results comments. Expected @expected',
+      SafeMarkup::format('There are exactly @results comments. Expected @expected',
         array('@results' => count($view->result), '@expected' => $this->blockDisplayResults)
       )
     );
diff --git a/core/modules/config/src/Tests/ConfigCRUDTest.php b/core/modules/config/src/Tests/ConfigCRUDTest.php
index c530b96..1d51054 100644
--- a/core/modules/config/src/Tests/ConfigCRUDTest.php
+++ b/core/modules/config/src/Tests/ConfigCRUDTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\config\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Config\ConfigNameException;
 use Drupal\Core\Config\ConfigValueException;
@@ -196,7 +197,7 @@ function testNameValidation() {
         unset($test_characters[$i]);
       }
     }
-    $this->assertTrue(empty($test_characters), format_string('Expected ConfigNameException was thrown for all invalid name characters: @characters', array(
+    $this->assertTrue(empty($test_characters), SafeMarkup::format('Expected ConfigNameException was thrown for all invalid name characters: @characters', array(
       '@characters' => implode(' ', $characters),
     )));
 
@@ -287,7 +288,7 @@ public function testDataTypes() {
       $this->fail('No Exception thrown upon saving invalid data type.');
     }
     catch (UnsupportedDataTypeConfigException $e) {
-      $this->pass(String::format('%class thrown upon saving invalid data type.', array(
+      $this->pass(SafeMarkup::format('%class thrown upon saving invalid data type.', array(
         '%class' => get_class($e),
       )));
     }
@@ -304,7 +305,7 @@ public function testDataTypes() {
       $this->fail('No Exception thrown upon saving invalid data type.');
     }
     catch (UnsupportedDataTypeConfigException $e) {
-      $this->pass(String::format('%class thrown upon saving invalid data type.', array(
+      $this->pass(SafeMarkup::format('%class thrown upon saving invalid data type.', array(
         '%class' => get_class($e),
       )));
     }
diff --git a/core/modules/config/src/Tests/ConfigDiffTest.php b/core/modules/config/src/Tests/ConfigDiffTest.php
index 10f6902..805e651 100644
--- a/core/modules/config/src/Tests/ConfigDiffTest.php
+++ b/core/modules/config/src/Tests/ConfigDiffTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\config\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\KernelTestBase;
 
 /**
@@ -53,8 +54,8 @@ function testDiff() {
     $diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name);
     $edits = $diff->getEdits();
     $this->assertEqual($edits[0]->type, 'change', 'The first item in the diff is a change.');
-    $this->assertEqual($edits[0]->orig[0], $change_key . ': ' . $original_data[$change_key], format_string("The active value for key '%change_key' is '%original_data'.", array('%change_key' => $change_key, '%original_data' => $original_data[$change_key])));
-    $this->assertEqual($edits[0]->closing[0], $change_key . ': ' . $change_data, format_string("The staging value for key '%change_key' is '%change_data'.", array('%change_key' => $change_key, '%change_data' => $change_data)));
+    $this->assertEqual($edits[0]->orig[0], $change_key . ': ' . $original_data[$change_key], SafeMarkup::format("The active value for key '%change_key' is '%original_data'.", array('%change_key' => $change_key, '%original_data' => $original_data[$change_key])));
+    $this->assertEqual($edits[0]->closing[0], $change_key . ': ' . $change_data, SafeMarkup::format("The staging value for key '%change_key' is '%change_data'.", array('%change_key' => $change_key, '%change_data' => $change_data)));
 
     // Reset data back to original, and remove a key
     $staging_data = $original_data;
@@ -66,8 +67,8 @@ function testDiff() {
     $edits = $diff->getEdits();
     $this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
     $this->assertEqual($edits[1]->type, 'delete', 'The second item in the diff is a delete.');
-    $this->assertEqual($edits[1]->orig[0], $remove_key . ': ' . $original_data[$remove_key], format_string("The active value for key '%remove_key' is '%original_data'.", array('%remove_key' => $remove_key, '%original_data' => $original_data[$remove_key])));
-    $this->assertFalse($edits[1]->closing, format_string("The key '%remove_key' does not exist in staging.", array('%remove_key' => $remove_key)));
+    $this->assertEqual($edits[1]->orig[0], $remove_key . ': ' . $original_data[$remove_key], SafeMarkup::format("The active value for key '%remove_key' is '%original_data'.", array('%remove_key' => $remove_key, '%original_data' => $original_data[$remove_key])));
+    $this->assertFalse($edits[1]->closing, SafeMarkup::format("The key '%remove_key' does not exist in staging.", array('%remove_key' => $remove_key)));
 
     // Reset data back to original and add a key
     $staging_data = $original_data;
@@ -79,8 +80,8 @@ function testDiff() {
     $edits = $diff->getEdits();
     $this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
     $this->assertEqual($edits[1]->type, 'add', 'The second item in the diff is an add.');
-    $this->assertFalse($edits[1]->orig, format_string("The key '%add_key' does not exist in active.", array('%add_key' => $add_key)));
-    $this->assertEqual($edits[1]->closing[0], $add_key . ': ' . $add_data, format_string("The staging value for key '%add_key' is '%add_data'.", array('%add_key' => $add_key, '%add_data' => $add_data)));
+    $this->assertFalse($edits[1]->orig, SafeMarkup::format("The key '%add_key' does not exist in active.", array('%add_key' => $add_key)));
+    $this->assertEqual($edits[1]->closing[0], $add_key . ': ' . $add_data, SafeMarkup::format("The staging value for key '%add_key' is '%add_data'.", array('%add_key' => $add_key, '%add_data' => $add_data)));
 
     // Test diffing a renamed config entity.
     $test_entity_id = $this->randomMachineName();
diff --git a/core/modules/config/src/Tests/ConfigEntityStorageTest.php b/core/modules/config/src/Tests/ConfigEntityStorageTest.php
index 19bf959..324ab2a 100644
--- a/core/modules/config/src/Tests/ConfigEntityStorageTest.php
+++ b/core/modules/config/src/Tests/ConfigEntityStorageTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\config\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\KernelTestBase;
 use Drupal\Core\Config\ConfigDuplicateUUIDException;
 
@@ -46,7 +47,7 @@ public function testUUIDConflict() {
       $this->fail('Exception thrown when attempting to save a configuration entity with a UUID that does not match the existing UUID.');
     }
     catch (ConfigDuplicateUUIDException $e) {
-      $this->pass(format_string('Exception thrown when attempting to save a configuration entity with a UUID that does not match existing data: %e.', array('%e' => $e)));
+      $this->pass(SafeMarkup::format('Exception thrown when attempting to save a configuration entity with a UUID that does not match existing data: %e.', array('%e' => $e)));
     }
 
     // Ensure that the config entity was not corrupted.
diff --git a/core/modules/config/src/Tests/ConfigEntityTest.php b/core/modules/config/src/Tests/ConfigEntityTest.php
index ac93e87..d5261bd 100644
--- a/core/modules/config/src/Tests/ConfigEntityTest.php
+++ b/core/modules/config/src/Tests/ConfigEntityTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\config\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\EntityMalformedException;
 use Drupal\Core\Entity\EntityStorageException;
@@ -151,7 +152,7 @@ function testCRUD() {
     ));
     try {
       $id_length_config_test->save();
-      $this->pass(String::format("config_test entity with ID length @length was saved.", array(
+      $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", array(
         '@length' => strlen($id_length_config_test->id()))
       ));
     }
@@ -165,7 +166,7 @@ function testCRUD() {
     ));
     try {
       $id_length_config_test->save();
-      $this->pass(String::format("config_test entity with ID length @length was saved.", array(
+      $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", array(
         '@length' => strlen($id_length_config_test->id()),
       )));
     }
@@ -179,13 +180,13 @@ function testCRUD() {
     ));
     try {
       $status = $id_length_config_test->save();
-      $this->fail(String::format("config_test entity with ID length @length exceeding the maximum allowed length of @max saved successfully", array(
+      $this->fail(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max saved successfully", array(
         '@length' => strlen($id_length_config_test->id()),
         '@max' => static::MAX_ID_LENGTH,
       )));
     }
     catch (ConfigEntityIdLengthException $e) {
-      $this->pass(String::format("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", array(
+      $this->pass(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", array(
         '@length' => strlen($id_length_config_test->id()),
         '@max' => static::MAX_ID_LENGTH,
       )));
@@ -239,9 +240,9 @@ function testCRUDUI() {
     $label1 = $this->randomMachineName();
     $label2 = $this->randomMachineName();
     $label3 = $this->randomMachineName();
-    $message_insert = format_string('%label configuration has been created.', array('%label' => $label1));
-    $message_update = format_string('%label configuration has been updated.', array('%label' => $label2));
-    $message_delete = format_string('The test configuration %label has been deleted.', array('%label' => $label2));
+    $message_insert = SafeMarkup::format('%label configuration has been created.', array('%label' => $label1));
+    $message_update = SafeMarkup::format('%label configuration has been updated.', array('%label' => $label2));
+    $message_delete = SafeMarkup::format('The test configuration %label has been deleted.', array('%label' => $label2));
 
     // Create a configuration entity.
     $edit = array(
@@ -312,7 +313,7 @@ function testCRUDUI() {
     );
     $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
     $this->assertResponse(200);
-    $message_insert = format_string('%label configuration has been created.', array('%label' => $edit['label']));
+    $message_insert = SafeMarkup::format('%label configuration has been created.', array('%label' => $edit['label']));
     $this->assertRaw($message_insert);
     $this->assertLinkByHref('admin/structure/config_test/manage/0');
     $this->assertLinkByHref('admin/structure/config_test/manage/0/delete');
diff --git a/core/modules/config/src/Tests/ConfigFileContentTest.php b/core/modules/config/src/Tests/ConfigFileContentTest.php
index 3a62f85..46c11a2 100644
--- a/core/modules/config/src/Tests/ConfigFileContentTest.php
+++ b/core/modules/config/src/Tests/ConfigFileContentTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\config\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Config\FileStorage;
 use Drupal\simpletest\KernelTestBase;
 
@@ -121,16 +122,16 @@ function testReadWriteConfig() {
     $this->assertNull($config->get('i.dont.exist'), 'Non-existent nested value returned NULL.');
 
     // Read false value.
-    $this->assertEqual($config->get($false_key), '0', format_string("Boolean FALSE value returned the string '0'."));
+    $this->assertEqual($config->get($false_key), '0', SafeMarkup::format("Boolean FALSE value returned the string '0'."));
 
     // Read true value.
-    $this->assertEqual($config->get($true_key), '1', format_string("Boolean TRUE value returned the string '1'."));
+    $this->assertEqual($config->get($true_key), '1', SafeMarkup::format("Boolean TRUE value returned the string '1'."));
 
     // Read null value.
     $this->assertIdentical($config->get('null'), NULL);
 
     // Read false that had been nested in an array value.
-    $this->assertEqual($config->get($casting_array_false_value_key), '0', format_string("Nested boolean FALSE value returned the string '0'."));
+    $this->assertEqual($config->get($casting_array_false_value_key), '0', SafeMarkup::format("Nested boolean FALSE value returned the string '0'."));
 
     // Unset a top level value.
     $config->clear($key);
diff --git a/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php b/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php
index 9341f21..d92f60d 100644
--- a/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php
+++ b/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\config\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Component\Uuid\Php;
@@ -110,7 +111,7 @@ public function testRenameValidation() {
     catch (ConfigImporterException $e) {
       $this->pass('Expected ConfigImporterException thrown when a renamed configuration entity does not match the existing entity type.');
       $expected = array(
-        String::format('Entity type mismatch on rename. !old_type not equal to !new_type for existing configuration !old_name and staged configuration !new_name.', array('old_type' => 'node_type', 'new_type' => 'config_test', 'old_name' => 'node.type.' . $content_type->id(), 'new_name' => 'config_test.dynamic.' . $test_entity_id))
+        SafeMarkup::format('Entity type mismatch on rename. !old_type not equal to !new_type for existing configuration !old_name and staged configuration !new_name.', array('old_type' => 'node_type', 'new_type' => 'config_test', 'old_name' => 'node.type.' . $content_type->id(), 'new_name' => 'config_test.dynamic.' . $test_entity_id))
       );
       $this->assertIdentical($expected, $this->configImporter->getErrors());
     }
@@ -153,7 +154,7 @@ public function testRenameSimpleConfigValidation() {
     catch (ConfigImporterException $e) {
       $this->pass('Expected ConfigImporterException thrown when simple configuration is renamed.');
       $expected = array(
-        String::format('Rename operation for simple configuration. Existing configuration !old_name and staged configuration !new_name.', array('old_name' => 'config_test.old', 'new_name' => 'config_test.new'))
+        SafeMarkup::format('Rename operation for simple configuration. Existing configuration !old_name and staged configuration !new_name.', array('old_name' => 'config_test.old', 'new_name' => 'config_test.new'))
       );
       $this->assertIdentical($expected, $this->configImporter->getErrors());
     }
diff --git a/core/modules/config/src/Tests/ConfigImportUITest.php b/core/modules/config/src/Tests/ConfigImportUITest.php
index 4f3aea5..8bc9b1b 100644
--- a/core/modules/config/src/Tests/ConfigImportUITest.php
+++ b/core/modules/config/src/Tests/ConfigImportUITest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\config\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Config\InstallStorage;
 use Drupal\simpletest\WebTestBase;
@@ -290,7 +291,7 @@ function testImportDiff() {
 
     // Load the diff UI and verify that the diff reflects the change.
     $this->drupalGet('admin/config/development/configuration/sync/diff/' . $config_name);
-    $this->assertTitle(format_string('View changes of @config_name | Drupal', array('@config_name' => $config_name)));
+    $this->assertTitle(SafeMarkup::format('View changes of @config_name | Drupal', array('@config_name' => $config_name)));
 
     // Reset data back to original, and remove a key
     $staging_data = $original_data;
@@ -403,7 +404,7 @@ function testImportErrorLog() {
 
     // Attempt to import configuration and verify that an error message appears.
     $this->drupalPostForm(NULL, array(), t('Import all'));
-    $this->assertText(String::format('Deleted and replaced configuration entity "@name"', array('@name' => $name_secondary)));
+    $this->assertText(SafeMarkup::format('Deleted and replaced configuration entity "@name"', array('@name' => $name_secondary)));
     $this->assertText(t('The configuration was imported with errors.'));
     $this->assertNoText(t('The configuration was imported successfully.'));
     $this->assertText(t('There are no configuration changes to import.'));
@@ -423,11 +424,11 @@ public function testEntityBundleDelete() {
     $this->drupalGet('admin/config/development/configuration');
     // The node type, body field and entity displays will be scheduled for
     // removal.
-    $this->assertText(format_string('node.type.@type', array('@type' => $node_type->id())));
-    $this->assertText(format_string('field.field.node.@type.body', array('@type' => $node_type->id())));
-    $this->assertText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
-    $this->assertText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
-    $this->assertText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
+    $this->assertText(SafeMarkup::format('node.type.@type', array('@type' => $node_type->id())));
+    $this->assertText(SafeMarkup::format('field.field.node.@type.body', array('@type' => $node_type->id())));
+    $this->assertText(SafeMarkup::format('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
+    $this->assertText(SafeMarkup::format('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
+    $this->assertText(SafeMarkup::format('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
 
     // Attempt to import configuration and verify that an error message appears
     // and the node type, body field and entity displays are still scheduled for
@@ -435,22 +436,22 @@ public function testEntityBundleDelete() {
     $this->drupalPostForm(NULL, array(), t('Import all'));
     $validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', array('%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label()));
     $this->assertRaw($validation_message);
-    $this->assertText(format_string('node.type.@type', array('@type' => $node_type->id())));
-    $this->assertText(format_string('field.field.node.@type.body', array('@type' => $node_type->id())));
-    $this->assertText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
-    $this->assertText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
-    $this->assertText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
+    $this->assertText(SafeMarkup::format('node.type.@type', array('@type' => $node_type->id())));
+    $this->assertText(SafeMarkup::format('field.field.node.@type.body', array('@type' => $node_type->id())));
+    $this->assertText(SafeMarkup::format('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
+    $this->assertText(SafeMarkup::format('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
+    $this->assertText(SafeMarkup::format('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
 
     // Delete the node and try to import again.
     $node->delete();
     $this->drupalPostForm(NULL, array(), t('Import all'));
     $this->assertNoRaw($validation_message);
     $this->assertText(t('There are no configuration changes to import.'));
-    $this->assertNoText(format_string('node.type.@type', array('@type' => $node_type->id())));
-    $this->assertNoText(format_string('field.field.node.@type.body', array('@type' => $node_type->id())));
-    $this->assertNoText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
-    $this->assertNoText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
-    $this->assertNoText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
+    $this->assertNoText(SafeMarkup::format('node.type.@type', array('@type' => $node_type->id())));
+    $this->assertNoText(SafeMarkup::format('field.field.node.@type.body', array('@type' => $node_type->id())));
+    $this->assertNoText(SafeMarkup::format('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
+    $this->assertNoText(SafeMarkup::format('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
+    $this->assertNoText(SafeMarkup::format('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
   }
 
 }
diff --git a/core/modules/config/src/Tests/ConfigImporterTest.php b/core/modules/config/src/Tests/ConfigImporterTest.php
index a6b2312..f55f050 100644
--- a/core/modules/config/src/Tests/ConfigImporterTest.php
+++ b/core/modules/config/src/Tests/ConfigImporterTest.php
@@ -249,7 +249,7 @@ function testSecondaryWritePrimaryFirst() {
 
     $logs = $this->configImporter->getErrors();
     $this->assertEqual(count($logs), 1);
-    $this->assertEqual($logs[0], String::format('Deleted and replaced configuration entity "@name"', array('@name' => $name_secondary)));
+    $this->assertEqual($logs[0], SafeMarkup::format('Deleted and replaced configuration entity "@name"', array('@name' => $name_secondary)));
   }
 
   /**
@@ -295,8 +295,8 @@ function testSecondaryWriteSecondaryFirst() {
 
     $logs = $this->configImporter->getErrors();
     $this->assertEqual(count($logs), 1);
-    $message = String::format('config_test entity with ID @name already exists', array('@name' => 'secondary'));
-    $this->assertEqual($logs[0], String::format('Unexpected error during import with operation @op for @name: @message.', array('@op' => 'create', '@name' => $name_primary, '@message' => $message)));
+    $message = SafeMarkup::format('config_test entity with ID @name already exists', array('@name' => 'secondary'));
+    $this->assertEqual($logs[0], SafeMarkup::format('Unexpected error during import with operation @op for @name: @message.', array('@op' => 'create', '@name' => $name_primary, '@message' => $message)));
   }
 
   /**
@@ -378,7 +378,7 @@ function testSecondaryUpdateDeletedDeleterFirst() {
 
     $logs = $this->configImporter->getErrors();
     $this->assertEqual(count($logs), 1);
-    $this->assertEqual($logs[0], String::format('Update target "@name" is missing.', array('@name' => $name_deletee)));
+    $this->assertEqual($logs[0], SafeMarkup::format('Update target "@name" is missing.', array('@name' => $name_deletee)));
   }
 
   /**
diff --git a/core/modules/config/src/Tests/SchemaCheckTestTrait.php b/core/modules/config/src/Tests/SchemaCheckTestTrait.php
index 9f7cf2a..0365b61 100644
--- a/core/modules/config/src/Tests/SchemaCheckTestTrait.php
+++ b/core/modules/config/src/Tests/SchemaCheckTestTrait.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\config\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Config\TypedConfigManagerInterface;
 use Drupal\Core\Config\Schema\SchemaCheckTrait;
 use Drupal\Component\Utility\String;
@@ -33,19 +34,19 @@ public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $c
     if ($errors === FALSE) {
       // @todo Since the use of this trait is under TestBase, it works.
       //  Can be fixed as part of https://drupal.org/node/2260053.
-      $this->fail(String::format('No schema for !config_name', array('!config_name' => $config_name)));
+      $this->fail(SafeMarkup::format('No schema for !config_name', array('!config_name' => $config_name)));
       return;
     }
     elseif ($errors === TRUE) {
       // @todo Since the use of this trait is under TestBase, it works.
       //  Can be fixed as part of https://drupal.org/node/2260053.
-      $this->pass(String::format('Schema found for !config_name and values comply with schema.', array('!config_name' => $config_name)));
+      $this->pass(SafeMarkup::format('Schema found for !config_name and values comply with schema.', array('!config_name' => $config_name)));
     }
     else {
       foreach ($errors as $key => $error) {
         // @todo Since the use of this trait is under TestBase, it works.
         //  Can be fixed as part of https://drupal.org/node/2260053.
-        $this->fail(String::format('Schema key @key failed with: @error', array('@key' => $key, '@error' => $error)));
+        $this->fail(SafeMarkup::format('Schema key @key failed with: @error', array('@key' => $key, '@error' => $error)));
       }
     }
   }
diff --git a/core/modules/config/tests/config_test/src/ConfigTestForm.php b/core/modules/config/tests/config_test/src/ConfigTestForm.php
index 56195e2..3b7661d 100644
--- a/core/modules/config/tests/config_test/src/ConfigTestForm.php
+++ b/core/modules/config/tests/config_test/src/ConfigTestForm.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\config_test;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\EntityForm;
 use Drupal\Core\Form\FormStateInterface;
 
@@ -133,10 +134,10 @@ public function save(array $form, FormStateInterface $form_state) {
     $status = $entity->save();
 
     if ($status === SAVED_UPDATED) {
-      drupal_set_message(format_string('%label configuration has been updated.', array('%label' => $entity->label())));
+      drupal_set_message(SafeMarkup::format('%label configuration has been updated.', array('%label' => $entity->label())));
     }
     else {
-      drupal_set_message(format_string('%label configuration has been created.', array('%label' => $entity->label())));
+      drupal_set_message(SafeMarkup::format('%label configuration has been created.', array('%label' => $entity->label())));
     }
 
     $form_state->setRedirectUrl($this->entity->urlInfo('collection'));
diff --git a/core/modules/config_translation/src/ConfigMapperManager.php b/core/modules/config_translation/src/ConfigMapperManager.php
index 09b6498..30a6789 100644
--- a/core/modules/config_translation/src/ConfigMapperManager.php
+++ b/core/modules/config_translation/src/ConfigMapperManager.php
@@ -124,7 +124,7 @@ public function processDefinition(&$definition, $plugin_id) {
     parent::processDefinition($definition, $plugin_id);
 
     if (!isset($definition['base_route_name'])) {
-      throw new InvalidPluginDefinitionException($plugin_id, String::format("The plugin definition of the mapper '%plugin_id' does not contain a base_route_name.", array('%plugin_id' => $plugin_id)));
+      throw new InvalidPluginDefinitionException($plugin_id, SafeMarkup::format("The plugin definition of the mapper '%plugin_id' does not contain a base_route_name.", array('%plugin_id' => $plugin_id)));
     }
   }
 
diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php
index ae0d250..8e1f1c0 100644
--- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php
+++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\config_translation\Tests;
 
 use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Config\FileStorage;
@@ -851,12 +852,12 @@ public function testTextFormatTranslation() {
    */
   protected function getTranslation($config_name, $key, $langcode) {
     $settings_locations = $this->localeStorage->getLocations(array('type' => 'configuration', 'name' => $config_name));
-    $this->assertTrue(!empty($settings_locations), format_string('Configuration locations found for %config_name.', array('%config_name' => $config_name)));
+    $this->assertTrue(!empty($settings_locations), SafeMarkup::format('Configuration locations found for %config_name.', array('%config_name' => $config_name)));
 
     if (!empty($settings_locations)) {
       $source = $this->container->get('config.factory')->get($config_name)->get($key);
       $source_string = $this->localeStorage->findString(array('source' => $source, 'type' => 'configuration'));
-      $this->assertTrue(!empty($source_string), format_string('Found string for %config_name.%key.', array('%config_name' => $config_name, '%key' => $key)));
+      $this->assertTrue(!empty($source_string), SafeMarkup::format('Found string for %config_name.%key.', array('%config_name' => $config_name, '%key' => $key)));
 
       if (!empty($source_string)) {
         $conditions = array(
@@ -918,17 +919,17 @@ protected function assertDisabledTextarea($id) {
       ':id' => $id,
     ));
     $textarea = reset($textarea);
-    $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, String::format('Disabled field @id exists.', array(
+    $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', array(
       '@id' => $id,
     )));
     $expected = 'This field has been disabled because you do not have sufficient permissions to edit it.';
-    $passed = $passed && $this->assertEqual((string) $textarea, $expected, String::format('Disabled textarea @id hides text in an inaccessible text format.', array(
+    $passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', array(
       '@id' => $id,
     )));
     // Make sure the text format select is not shown.
     $select_id = str_replace('value', 'format--2', $id);
     $select = $this->xpath('//select[@id=:id]', array(':id' => $select_id));
-    return $passed && $this->assertFalse($select, String::format('Field @id does not exist.', array(
+    return $passed && $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', array(
       '@id' => $id,
     )));
   }
diff --git a/core/modules/contact/src/Tests/ContactPersonalTest.php b/core/modules/contact/src/Tests/ContactPersonalTest.php
index 03965ad..56c4454 100644
--- a/core/modules/contact/src/Tests/ContactPersonalTest.php
+++ b/core/modules/contact/src/Tests/ContactPersonalTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\contact\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\simpletest\WebTestBase;
@@ -93,7 +94,7 @@ function testSendPersonalContactMessage() {
       '@sender_email' => $this->webUser->getEmail(),
       '@recipient_name' => $this->contactUser->getUsername()
     );
-    $this->assertText(String::format('@sender_name (@sender_email) sent @recipient_name an email.', $placeholders));
+    $this->assertText(SafeMarkup::format('@sender_name (@sender_email) sent @recipient_name an email.', $placeholders));
   }
 
   /**
diff --git a/core/modules/contact/src/Tests/ContactSitewideTest.php b/core/modules/contact/src/Tests/ContactSitewideTest.php
index 793388a..0dc764e 100644
--- a/core/modules/contact/src/Tests/ContactSitewideTest.php
+++ b/core/modules/contact/src/Tests/ContactSitewideTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\contact\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\contact\Entity\ContactForm;
 use Drupal\Core\Mail\MailFormatHelper;
@@ -81,7 +82,7 @@ function testSiteWideContact() {
     $edit_link = $this->xpath('//a[@href=:href]', array(
       ':href' => \Drupal::url('entity.contact_form.edit_form', array('contact_form' => 'personal'))
     ));
-    $this->assertTrue(empty($edit_link), format_string('No link containing href %href found.',
+    $this->assertTrue(empty($edit_link), SafeMarkup::format('No link containing href %href found.',
       array('%href' => 'admin/structure/contact/manage/personal')
     ));
     $this->assertNoLinkByHref('admin/structure/contact/manage/personal/delete');
@@ -128,7 +129,7 @@ function testSiteWideContact() {
     $max_length = EntityTypeInterface::BUNDLE_MAX_LENGTH;
     $max_length_exceeded = $max_length + 1;
     $this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', array($recipients[0])), '', TRUE);
-    $this->assertText(format_string('Machine-readable name cannot be longer than !max characters but is currently !exceeded characters long.', array('!max' => $max_length, '!exceeded' => $max_length_exceeded)));
+    $this->assertText(SafeMarkup::format('Machine-readable name cannot be longer than !max characters but is currently !exceeded characters long.', array('!max' => $max_length, '!exceeded' => $max_length_exceeded)));
     $this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', array($recipients[0])), '', TRUE);
     $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label)));
 
@@ -428,7 +429,7 @@ function deleteContactForms() {
       else {
         $this->drupalPostForm("admin/structure/contact/manage/$id/delete", array(), t('Delete'));
         $this->assertRaw(t('The contact form %label has been deleted.', array('%label' => $contact_form->label())));
-        $this->assertFalse(ContactForm::load($id), format_string('Form %contact_form not found', array('%contact_form' => $contact_form->label())));
+        $this->assertFalse(ContactForm::load($id), SafeMarkup::format('Form %contact_form not found', array('%contact_form' => $contact_form->label())));
       }
     }
   }
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php
index 9874574..21c1a38 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php
@@ -9,6 +9,7 @@
 
 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
 use Drupal\comment\Tests\CommentTestTrait;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Field\Entity\BaseFieldOverride;
 use Drupal\Core\Language\Language;
 use Drupal\field\Entity\FieldConfig;
@@ -219,7 +220,7 @@ function testAccountLanguageSettingsUI() {
   protected function assertSettings($entity_type, $bundle, $enabled, $edit) {
     $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
     $args = array('@entity_type' => $entity_type, '@bundle' => $bundle, '@enabled' => $enabled ? 'enabled' : 'disabled');
-    $message = format_string('Translation for entity @entity_type (@bundle) is @enabled.', $args);
+    $message = SafeMarkup::format('Translation for entity @entity_type (@bundle) is @enabled.', $args);
     \Drupal::entityManager()->clearCachedDefinitions();
     return $this->assertEqual(\Drupal::service('content_translation.manager')->isEnabled($entity_type, $bundle), $enabled, $message);
   }
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
index cbae0d4..cf75c11 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\content_translation\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\EntityInterface;
 
 /**
@@ -198,13 +199,13 @@ function testImageFieldSync() {
       $value = $values[$default_langcode][$item->target_id];
       $source_item = $translation->{$this->fieldName}->get($delta);
       $assert = $item->target_id == $source_item->target_id && $item->alt == $value['alt'] && $item->title == $value['title'];
-      $this->assertTrue($assert, format_string('Field item @fid has been successfully synchronized.', array('@fid' => $item->target_id)));
+      $this->assertTrue($assert, SafeMarkup::format('Field item @fid has been successfully synchronized.', array('@fid' => $item->target_id)));
       $fids[$item->target_id] = TRUE;
     }
 
     // Check that the dropped value is the right one.
     $removed_fid = $this->files[0]->fid;
-    $this->assertTrue(!isset($fids[$removed_fid]), format_string('Field item @fid has been correctly removed.', array('@fid' => $removed_fid)));
+    $this->assertTrue(!isset($fids[$removed_fid]), SafeMarkup::format('Field item @fid has been correctly removed.', array('@fid' => $removed_fid)));
 
     // Add back an item for the dropped value and perform synchronization again.
     $values[$langcode][$removed_fid] = array(
@@ -228,7 +229,7 @@ function testImageFieldSync() {
       $value = $values[$fid_langcode][$item->target_id];
       $source_item = $translation->{$this->fieldName}->get($delta);
       $assert = $item->target_id == $source_item->target_id && $item->alt == $value['alt'] && $item->title == $value['title'];
-      $this->assertTrue($assert, format_string('Field item @fid has been successfully synchronized.', array('@fid' => $item->target_id)));
+      $this->assertTrue($assert, SafeMarkup::format('Field item @fid has been successfully synchronized.', array('@fid' => $item->target_id)));
     }
   }
 
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationUITest.php b/core/modules/content_translation/src/Tests/ContentTranslationUITest.php
index 9ed362b..ca7d58e 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationUITest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationUITest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\content_translation\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Language\LanguageInterface;
@@ -64,7 +65,7 @@ protected function doTestBasicTranslation() {
     foreach ($values[$default_langcode] as $property => $value) {
       $stored_value = $this->getValue($translation, $property, $default_langcode);
       $value = is_array($value) ? $value[0]['value'] : $value;
-      $message = format_string('@property correctly stored in the default language.', array('@property' => $property));
+      $message = SafeMarkup::format('@property correctly stored in the default language.', array('@property' => $property));
       $this->assertEqual($stored_value, $value, $message);
     }
 
@@ -120,7 +121,7 @@ protected function doTestBasicTranslation() {
       foreach ($property_values as $property => $value) {
         $stored_value = $this->getValue($translation, $property, $langcode);
         $value = is_array($value) ? $value[0]['value'] : $value;
-        $message = format_string('%property correctly stored with language %language.', array('%property' => $property, '%language' => $langcode));
+        $message = SafeMarkup::format('%property correctly stored with language %language.', array('%property' => $property, '%language' => $langcode));
         $this->assertEqual($stored_value, $value, $message);
       }
     }
@@ -138,10 +139,10 @@ protected function doTestTranslationOverview() {
         $language = new Language(array('id' => $langcode));
         $view_path = $entity->url('canonical', array('language' => $language));
         $elements = $this->xpath('//table//a[@href=:href]', array(':href' => $view_path));
-        $this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', array('%language' => $langcode)));
+        $this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label(), SafeMarkup::format('Label correctly shown for %language translation.', array('%language' => $langcode)));
         $edit_path = $entity->url('edit-form', array('language' => $language));
         $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', array(':href' => $edit_path));
-        $this->assertEqual((string) $elements[0], t('Edit'), format_string('Edit link correct for %language translation.', array('%language' => $langcode)));
+        $this->assertEqual((string) $elements[0], t('Edit'), SafeMarkup::format('Edit link correct for %language translation.', array('%language' => $langcode)));
       }
     }
   }
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php
index 709ee68..22501aa 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\content_translation\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Core\Url;
 use Drupal\user\UserInterface;
@@ -93,10 +94,10 @@ function testWorkflows() {
 
       foreach ($ops as $op => $label) {
         if ($op != $current_op) {
-          $this->assertNoLink($label, format_string('No %op link found.', array('%op' => $label)));
+          $this->assertNoLink($label, SafeMarkup::format('No %op link found.', array('%op' => $label)));
         }
         else {
-          $this->assertLink($label, 0, format_string('%op link found.', array('%op' => $label)));
+          $this->assertLink($label, 0, SafeMarkup::format('%op link found.', array('%op' => $label)));
         }
       }
     }
@@ -121,14 +122,14 @@ protected function assertWorkflows(UserInterface $user, $expected_status) {
     $options = array('language' => $languages[$default_langcode], 'absolute' => TRUE);
     $edit_url = $this->entity->urlInfo('edit-form', $options);
     $this->drupalGet($edit_url, $options);
-    $this->assertResponse($expected_status['edit'], format_string('The @user_label has the expected edit access.', $args));
+    $this->assertResponse($expected_status['edit'], SafeMarkup::format('The @user_label has the expected edit access.', $args));
 
     // Check whether the user is allowed to access the translation overview.
     $langcode = $this->langcodes[1];
     $options = array('language' => $languages[$langcode], 'absolute' => TRUE);
     $translations_url = $this->entity->url('drupal:content-translation-overview', $options);
     $this->drupalGet($translations_url);
-    $this->assertResponse($expected_status['overview'], format_string('The @user_label has the expected translation overview access.', $args));
+    $this->assertResponse($expected_status['overview'], SafeMarkup::format('The @user_label has the expected translation overview access.', $args));
 
     // Check whether the user is allowed to create a translation.
     $add_translation_url = Url::fromRoute('content_translation.translation_add_' . $this->entityTypeId, [$this->entityTypeId => $this->entity->id(), 'source' => $default_langcode, 'target' => $langcode], $options);
@@ -144,7 +145,7 @@ protected function assertWorkflows(UserInterface $user, $expected_status) {
     else {
       $this->drupalGet($add_translation_url);
     }
-    $this->assertResponse($expected_status['add_translation'], format_string('The @user_label has the expected translation creation access.', $args));
+    $this->assertResponse($expected_status['add_translation'], SafeMarkup::format('The @user_label has the expected translation creation access.', $args));
 
     // Check whether the user is allowed to edit a translation.
     $langcode = $this->langcodes[2];
@@ -174,7 +175,7 @@ protected function assertWorkflows(UserInterface $user, $expected_status) {
     else {
       $this->drupalGet($edit_translation_url);
     }
-    $this->assertResponse($expected_status['edit_translation'], format_string('The @user_label has the expected translation creation access.', $args));
+    $this->assertResponse($expected_status['edit_translation'], SafeMarkup::format('The @user_label has the expected translation creation access.', $args));
   }
 
   /**
diff --git a/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php b/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php
index 8701087..1afe1b0 100644
--- a/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php
+++ b/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\contextual\Tests;
 
 use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 use Drupal\Core\Template\Attribute;
 
@@ -138,7 +139,7 @@ function testDifferentPermissions() {
    * @return bool
    */
   protected function assertContextualLinkPlaceHolder($id) {
-    $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
+    $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', SafeMarkup::format('Contextual link placeholder with id @id exists.', array('@id' => $id)));
   }
 
   /**
@@ -150,7 +151,7 @@ protected function assertContextualLinkPlaceHolder($id) {
    * @return bool
    */
   protected function assertNoContextualLinkPlaceHolder($id) {
-    $this->assertNoRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id does not exist.', array('@id' => $id)));
+    $this->assertNoRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', SafeMarkup::format('Contextual link placeholder with id @id does not exist.', array('@id' => $id)));
   }
 
   /**
diff --git a/core/modules/datetime/src/Tests/DateTimeFieldTest.php b/core/modules/datetime/src/Tests/DateTimeFieldTest.php
index e2223dc..8b9027a 100644
--- a/core/modules/datetime/src/Tests/DateTimeFieldTest.php
+++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\datetime\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Entity\Entity\EntityViewDisplay;
 use Drupal\Core\Datetime\DrupalDateTime;
@@ -140,7 +141,7 @@ function testDateField() {
             // Verify that a date is displayed.
             $expected = format_date($date->getTimestamp(), $new_value);
             $this->renderTestEntity($id);
-            $this->assertText($expected, format_string('Formatted date field using %value format displayed as %expected.', array('%value' => $new_value, '%expected' => $expected)));
+            $this->assertText($expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected.', array('%value' => $new_value, '%expected' => $expected)));
             break;
         }
       }
@@ -154,7 +155,7 @@ function testDateField() {
       ->save();
     $expected = $date->format(DATETIME_DATE_STORAGE_FORMAT);
     $this->renderTestEntity($id);
-    $this->assertText($expected, format_string('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+    $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
   }
 
   /**
@@ -206,7 +207,7 @@ function testDatetimeField() {
             // Verify that a date is displayed.
             $expected = format_date($date->getTimestamp(), $new_value);
             $this->renderTestEntity($id);
-            $this->assertText($expected, format_string('Formatted date field using %value format displayed as %expected.', array('%value' => $new_value, '%expected' => $expected)));
+            $this->assertText($expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected.', array('%value' => $new_value, '%expected' => $expected)));
             break;
         }
       }
@@ -220,7 +221,7 @@ function testDatetimeField() {
       ->save();
     $expected = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
     $this->renderTestEntity($id);
-    $this->assertText($expected, format_string('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+    $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
   }
 
   /**
@@ -417,7 +418,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => '00:00:00',
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid year value %date has been caught.', array('%date' => $date_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid year value %date has been caught.', array('%date' => $date_value)));
 
     $date_value = '2012-75-01';
     $edit = array(
@@ -425,7 +426,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => '00:00:00',
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid month value %date has been caught.', array('%date' => $date_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid month value %date has been caught.', array('%date' => $date_value)));
 
     $date_value = '2012-12-99';
     $edit = array(
@@ -433,7 +434,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => '00:00:00',
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid day value %date has been caught.', array('%date' => $date_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid day value %date has been caught.', array('%date' => $date_value)));
 
     $date_value = '2012-12-01';
     $time_value = '';
@@ -451,7 +452,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => $time_value,
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid hour value %time has been caught.', array('%time' => $time_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid hour value %time has been caught.', array('%time' => $time_value)));
 
     $date_value = '2012-12-01';
     $time_value = '12:99:00';
@@ -460,7 +461,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => $time_value,
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid minute value %time has been caught.', array('%time' => $time_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid minute value %time has been caught.', array('%time' => $time_value)));
 
     $date_value = '2012-12-01';
     $time_value = '12:15:99';
@@ -469,7 +470,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => $time_value,
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid second value %time has been caught.', array('%time' => $time_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid second value %time has been caught.', array('%time' => $time_value)));
   }
 
   /**
diff --git a/core/modules/dblog/src/Logger/DbLog.php b/core/modules/dblog/src/Logger/DbLog.php
index 451be3a..8cf29ba 100644
--- a/core/modules/dblog/src/Logger/DbLog.php
+++ b/core/modules/dblog/src/Logger/DbLog.php
@@ -52,7 +52,7 @@ public function log($level, $message, array $context = array()) {
     // Remove any backtraces since they may contain an unserializable variable.
     unset($context['backtrace']);
 
-    // Convert PSR3-style messages to String::format() style, so they can be
+    // Convert PSR3-style messages to SafeMarkup::format() style, so they can be
     // translated too in runtime.
     $message_placeholders = $this->parser->parseMessagePlaceholders($message, $context);
 
diff --git a/core/modules/dblog/src/Plugin/views/field/DblogMessage.php b/core/modules/dblog/src/Plugin/views/field/DblogMessage.php
index 67c5e4c..1811b71 100644
--- a/core/modules/dblog/src/Plugin/views/field/DblogMessage.php
+++ b/core/modules/dblog/src/Plugin/views/field/DblogMessage.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\dblog\Plugin\views\field;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\Plugin\views\field\FieldPluginBase;
@@ -65,7 +66,7 @@ public function render(ResultRow $values) {
 
     if ($this->options['replace_variables']) {
       $variables = unserialize($this->getvalue($values, 'variables'));
-      return String::format($value, (array) $variables);
+      return SafeMarkup::format($value, (array) $variables);
     }
     else {
       return $this->sanitizeValue($value);
diff --git a/core/modules/dblog/src/Tests/DbLogTest.php b/core/modules/dblog/src/Tests/DbLogTest.php
index 9726fff..1ec32b9 100644
--- a/core/modules/dblog/src/Tests/DbLogTest.php
+++ b/core/modules/dblog/src/Tests/DbLogTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\dblog\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Logger\RfcLogLevel;
@@ -100,7 +101,7 @@ private function verifyRowLimit($row_limit) {
 
     // Check row limit variable.
     $current_limit = $this->config('dblog.settings')->get('row_limit');
-    $this->assertTrue($current_limit == $row_limit, format_string('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit)));
+    $this->assertTrue($current_limit == $row_limit, SafeMarkup::format('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit)));
   }
 
   /**
@@ -114,14 +115,14 @@ private function verifyCron($row_limit) {
     $this->generateLogEntries($row_limit + 10);
     // Verify that the database log row count exceeds the row limit.
     $count = db_query('SELECT COUNT(wid) FROM {watchdog}')->fetchField();
-    $this->assertTrue($count > $row_limit, format_string('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $row_limit)));
+    $this->assertTrue($count > $row_limit, SafeMarkup::format('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $row_limit)));
 
     // Run a cron job.
     $this->cronRun();
     // Verify that the database log row count equals the row limit plus one
     // because cron adds a record after it runs.
     $count = db_query('SELECT COUNT(wid) FROM {watchdog}')->fetchField();
-    $this->assertTrue($count == $row_limit + 1, format_string('Dblog row count of @count equals row limit of @limit plus one', array('@count' => $count, '@limit' => $row_limit)));
+    $this->assertTrue($count == $row_limit + 1, SafeMarkup::format('Dblog row count of @count equals row limit of @limit plus one', array('@count' => $count, '@limit' => $row_limit)));
   }
 
   /**
@@ -265,7 +266,7 @@ private function doUser() {
     $this->assertResponse(200);
     // Retrieve the user object.
     $user = user_load_by_name($name);
-    $this->assertTrue($user != NULL, format_string('User @name was loaded', array('@name' => $name)));
+    $this->assertTrue($user != NULL, SafeMarkup::format('User @name was loaded', array('@name' => $name)));
     // pass_raw property is needed by drupalLogin.
     $user->pass_raw = $pass;
     // Login user.
@@ -278,7 +279,7 @@ private function doUser() {
       $ids[] = $row->wid;
     }
     $count_before = (isset($ids)) ? count($ids) : 0;
-    $this->assertTrue($count_before > 0, format_string('DBLog contains @count records for @name', array('@count' => $count_before, '@name' => $user->getUsername())));
+    $this->assertTrue($count_before > 0, SafeMarkup::format('DBLog contains @count records for @name', array('@count' => $count_before, '@name' => $user->getUsername())));
 
     // Login the admin user.
     $this->drupalLogin($this->adminUser);
@@ -351,7 +352,7 @@ private function doNode($type) {
     $this->assertResponse(200);
     // Retrieve the node object.
     $node = $this->drupalGetNodeByTitle($title);
-    $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title)));
+    $this->assertTrue($node != NULL, SafeMarkup::format('Node @title was loaded', array('@title' => $title)));
     // Edit the node.
     $edit = $this->getContentUpdate($type);
     $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
@@ -464,7 +465,7 @@ public function testDBLogAddAndClear() {
     // Add a watchdog entry.
     $this->container->get('logger.dblog')->log($log['severity'], $log['message'], $log);
     // Make sure the table count has actually been incremented.
-    $this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), format_string('\Drupal\dblog\Logger\DbLog->log() added an entry to the dblog :count', array(':count' => $count)));
+    $this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), SafeMarkup::format('\Drupal\dblog\Logger\DbLog->log() added an entry to the dblog :count', array(':count' => $count)));
     // Login the admin user.
     $this->drupalLogin($this->adminUser);
     // Post in order to clear the database table.
@@ -473,7 +474,7 @@ public function testDBLogAddAndClear() {
     $this->drupalPostForm(NULL, array(), 'Confirm');
     // Count the rows in watchdog that previously related to the deleted user.
     $count = db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField();
-    $this->assertEqual($count, 0, format_string('DBLog contains :count records after a clear.', array(':count' => $count)));
+    $this->assertEqual($count, 0, SafeMarkup::format('DBLog contains :count records after a clear.', array(':count' => $count)));
   }
 
   /**
diff --git a/core/modules/dblog/src/Tests/Views/ViewsIntegrationTest.php b/core/modules/dblog/src/Tests/Views/ViewsIntegrationTest.php
index b63aa91..7974897 100644
--- a/core/modules/dblog/src/Tests/Views/ViewsIntegrationTest.php
+++ b/core/modules/dblog/src/Tests/Views/ViewsIntegrationTest.php
@@ -95,7 +95,7 @@ public function testIntegration() {
     $view->initStyle();
 
     foreach ($entries as $index => $entry) {
-      $this->assertEqual($view->style_plugin->getField($index, 'message'), String::format($entry['message'], $entry['variables']));
+      $this->assertEqual($view->style_plugin->getField($index, 'message'), SafeMarkup::format($entry['message'], $entry['variables']));
       $this->assertEqual($view->style_plugin->getField($index, 'link'), Xss::filterAdmin($entry['variables']['link']));
     }
 
diff --git a/core/modules/editor/src/Tests/EditorSecurityTest.php b/core/modules/editor/src/Tests/EditorSecurityTest.php
index f63fce2..62563e4 100644
--- a/core/modules/editor/src/Tests/EditorSecurityTest.php
+++ b/core/modules/editor/src/Tests/EditorSecurityTest.php
@@ -281,7 +281,7 @@ function testInitialSecurity() {
     // Log in as each user that may edit the content, and assert the value.
     foreach ($expected as $case) {
       foreach ($case['users'] as $account) {
-        $this->pass(format_string('Scenario: sample %sample_id, %format.', array(
+        $this->pass(SafeMarkup::format('Scenario: sample %sample_id, %format.', array(
           '%sample_id' => $case['node_id'],
           '%format' => $case['format'],
         )));
@@ -400,7 +400,7 @@ function testSwitchingSecurity() {
 
       // Switch to every other text format/editor and verify the results.
       foreach ($case['switch_to'] as $format => $expected_filtered_value) {
-        $this->pass(format_string('Scenario: sample %sample_id, switch from %original_format to %format.', array(
+        $this->pass(SafeMarkup::format('Scenario: sample %sample_id, switch from %original_format to %format.', array(
           '%sample_id' => $case['node_id'],
           '%original_format' => $case['format'],
           '%format' => $format,
diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceIntegrationTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceIntegrationTest.php
index 53fbcce..2729176 100644
--- a/core/modules/entity_reference/src/Tests/EntityReferenceIntegrationTest.php
+++ b/core/modules/entity_reference/src/Tests/EntityReferenceIntegrationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\entity_reference\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\config\Tests\AssertConfigEntityImportTrait;
 use Drupal\Core\Config\Entity\ConfigEntityBase;
@@ -152,7 +153,7 @@ public function testSupportedEntityTypesAndWidgets() {
       // Ensure the configuration has the expected dependency on the entity that
       // is being used a default value.
       $field = FieldConfig::loadByName($this->entityType, $this->bundle, $this->fieldName);
-      $this->assertTrue(in_array($referenced_entities[0]->getConfigDependencyName(), $field->getDependencies()[$key]), String::format('Expected @type dependency @name found', ['@type' => $key, '@name' => $referenced_entities[0]->getConfigDependencyName()]));
+      $this->assertTrue(in_array($referenced_entities[0]->getConfigDependencyName(), $field->getDependencies()[$key]), SafeMarkup::format('Expected @type dependency @name found', ['@type' => $key, '@name' => $referenced_entities[0]->getConfigDependencyName()]));
       // Ensure that the field can be imported without change even after the
       // default value deleted.
       $referenced_entities[0]->delete();
@@ -166,7 +167,7 @@ public function testSupportedEntityTypesAndWidgets() {
       $field = FieldConfig::loadByName($this->entityType, $this->bundle, $this->fieldName);
       $field->save();
       $dependencies = $field->getDependencies();
-      $this->assertFalse(isset($dependencies[$key]) && in_array($referenced_entities[0]->getConfigDependencyName(), $dependencies[$key]), String::format('@type dependency @name does not exist.', ['@type' => $key, '@name' => $referenced_entities[0]->getConfigDependencyName()]));
+      $this->assertFalse(isset($dependencies[$key]) && in_array($referenced_entities[0]->getConfigDependencyName(), $dependencies[$key]), SafeMarkup::format('@type dependency @name does not exist.', ['@type' => $key, '@name' => $referenced_entities[0]->getConfigDependencyName()]));
     }
   }
 
@@ -181,7 +182,7 @@ public function testSupportedEntityTypesAndWidgets() {
   protected function assertFieldValues($entity_name, $referenced_entities) {
     $entity = current(entity_load_multiple_by_properties($this->entityType, array('name' => $entity_name)));
 
-    $this->assertTrue($entity, format_string('%entity_type: Entity found in the database.', array('%entity_type' => $this->entityType)));
+    $this->assertTrue($entity, SafeMarkup::format('%entity_type: Entity found in the database.', array('%entity_type' => $this->entityType)));
 
     $this->assertEqual($entity->{$this->fieldName}->target_id, $referenced_entities[0]->id());
     $this->assertEqual($entity->{$this->fieldName}->entity->id(), $referenced_entities[0]->id());
diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php
index 802bc1b..44948c5 100644
--- a/core/modules/field/src/Entity/FieldConfig.php
+++ b/core/modules/field/src/Entity/FieldConfig.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Field\FieldConfigBase;
@@ -96,12 +97,12 @@ public function __construct(array $values, $entity_type = 'field_config') {
         throw new FieldException('Attempt to create a field without a field_name.');
       }
       if (empty($values['entity_type'])) {
-        throw new FieldException(String::format('Attempt to create a field @field_name without an entity_type.', array('@field_name' => $values['field_name'])));
+        throw new FieldException(SafeMarkup::format('Attempt to create a field @field_name without an entity_type.', array('@field_name' => $values['field_name'])));
       }
     }
     // 'bundle' is required in either case.
     if (empty($values['bundle'])) {
-      throw new FieldException(String::format('Attempt to create a field @field_name without a bundle.', array('@field_name' => $values['field_name'])));
+      throw new FieldException(SafeMarkup::format('Attempt to create a field @field_name without a bundle.', array('@field_name' => $values['field_name'])));
     }
 
     parent::__construct($values, $entity_type);
@@ -274,9 +275,9 @@ public function getFieldStorageDefinition() {
     if (!$this->fieldStorage) {
       $fields = $this->entityManager()->getFieldStorageDefinitions($this->entity_type);
       if (!isset($fields[$this->field_name])) {
-        throw new FieldException(String::format('Attempt to create a field @field_name that does not exist on entity type @entity_type.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type)));      }
+        throw new FieldException(SafeMarkup::format('Attempt to create a field @field_name that does not exist on entity type @entity_type.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type)));      }
       if (!$fields[$this->field_name] instanceof FieldStorageConfigInterface) {
-        throw new FieldException(String::format('Attempt to create a configurable field of non-configurable field storage @field_name.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type)));
+        throw new FieldException(SafeMarkup::format('Attempt to create a configurable field of non-configurable field storage @field_name.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type)));
       }
       $this->fieldStorage = $fields[$this->field_name];
     }
diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php
index fd3bd14..6e755a8 100644
--- a/core/modules/field/src/Entity/FieldStorageConfig.php
+++ b/core/modules/field/src/Entity/FieldStorageConfig.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Config\Entity\ConfigEntityBase;
@@ -229,13 +230,13 @@ public function __construct(array $values, $entity_type = 'field_storage_config'
       throw new FieldException('Attempt to create a field storage without a field name.');
     }
     if (!preg_match('/^[_a-z]+[_a-z0-9]*$/', $values['field_name'])) {
-      throw new FieldException(String::format('Attempt to create a field storage @field_name with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character', array('@field_name' => $values['field_name'])));
+      throw new FieldException(SafeMarkup::format('Attempt to create a field storage @field_name with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character', array('@field_name' => $values['field_name'])));
     }
     if (empty($values['type'])) {
-      throw new FieldException(String::format('Attempt to create a field storage @field_name with no type.', array('@field_name' => $values['field_name'])));
+      throw new FieldException(SafeMarkup::format('Attempt to create a field storage @field_name with no type.', array('@field_name' => $values['field_name'])));
     }
     if (empty($values['entity_type'])) {
-      throw new FieldException(String::format('Attempt to create a field storage @field_name with no entity_type.', array('@field_name' => $values['field_name'])));
+      throw new FieldException(SafeMarkup::format('Attempt to create a field storage @field_name with no entity_type.', array('@field_name' => $values['field_name'])));
     }
 
     parent::__construct($values, $entity_type);
@@ -296,7 +297,7 @@ protected function preSaveNew(EntityStorageInterface $storage) {
     // We use Unicode::strlen() because the DB layer assumes that column widths
     // are given in characters rather than bytes.
     if (Unicode::strlen($this->getName()) > static::NAME_MAX_LENGTH) {
-      throw new FieldException(String::format(
+      throw new FieldException(SafeMarkup::format(
         'Attempt to create a field storage with an name longer than @max characters: %name', array(
           '@max' => static::NAME_MAX_LENGTH,
           '%name' => $this->getName(),
@@ -307,13 +308,13 @@ protected function preSaveNew(EntityStorageInterface $storage) {
     // Disallow reserved field names.
     $disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->getTargetEntityTypeId()));
     if (in_array($this->getName(), $disallowed_field_names)) {
-      throw new FieldException(String::format('Attempt to create field storage %name which is reserved by entity type %type.', array('%name' => $this->getName(), '%type' => $this->getTargetEntityTypeId())));
+      throw new FieldException(SafeMarkup::format('Attempt to create field storage %name which is reserved by entity type %type.', array('%name' => $this->getName(), '%type' => $this->getTargetEntityTypeId())));
     }
 
     // Check that the field type is known.
     $field_type = $field_type_manager->getDefinition($this->getType(), FALSE);
     if (!$field_type) {
-      throw new FieldException(String::format('Attempt to create a field storage of unknown type %type.', array('%type' => $this->getType())));
+      throw new FieldException(SafeMarkup::format('Attempt to create a field storage of unknown type %type.', array('%type' => $this->getType())));
     }
     $this->module = $field_type['provider'];
 
diff --git a/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php b/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php
index 5152a18..5350109 100644
--- a/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php
+++ b/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests\Boolean;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
@@ -125,7 +126,7 @@ function testBooleanFormatterSettings() {
       foreach ($options as $string) {
         $this->assertText($string);
       }
-      $this->assertText(String::format($default, array('@on' => $values[0], '@off' => $values[1])));
+      $this->assertText(SafeMarkup::format($default, array('@on' => $values[0], '@off' => $values[1])));
     }
   }
 
diff --git a/core/modules/field/src/Tests/DisplayApiTest.php b/core/modules/field/src/Tests/DisplayApiTest.php
index 4123ab3..777e720 100644
--- a/core/modules/field/src/Tests/DisplayApiTest.php
+++ b/core/modules/field/src/Tests/DisplayApiTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\Entity\EntityViewMode;
 
 /**
@@ -126,7 +127,7 @@ function testFieldItemListView() {
     $setting = $settings['test_formatter_setting'];
     $this->assertText($this->label, 'Label was displayed.');
     foreach ($this->values as $delta => $value) {
-      $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+      $this->assertText($setting . '|' . $value['value'], SafeMarkup::format('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
 
     // Display settings: Check hidden field.
@@ -185,7 +186,7 @@ function testFieldItemListView() {
     $this->assertNoText($this->label, 'Label was not displayed.');
     $this->assertNoText('field_test_entity_display_build_alter', 'Alter not fired.');
     foreach ($this->values as $delta => $value) {
-      $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+      $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), SafeMarkup::format('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
 
     // View mode: check that display settings specified in the display object
@@ -195,7 +196,7 @@ function testFieldItemListView() {
     $setting = $this->display_options['teaser']['settings']['test_formatter_setting'];
     $this->assertText($this->label, 'Label was displayed.');
     foreach ($this->values as $delta => $value) {
-      $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+      $this->assertText($setting . '|' . $value['value'], SafeMarkup::format('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
 
     // Unknown view mode: check that display settings for 'default' view mode
@@ -205,7 +206,7 @@ function testFieldItemListView() {
     $setting = $this->display_options['default']['settings']['test_formatter_setting'];
     $this->assertText($this->label, 'Label was displayed.');
     foreach ($this->values as $delta => $value) {
-      $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+      $this->assertText($setting . '|' . $value['value'], SafeMarkup::format('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
   }
 
@@ -220,7 +221,7 @@ function testFieldItemView() {
       $item = $this->entity->{$this->field_name}[$delta];
       $build = $item->view();
       $this->render($build);
-      $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+      $this->assertText($setting . '|' . $value['value'], SafeMarkup::format('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
 
     // Check that explicit display settings are used.
@@ -235,7 +236,7 @@ function testFieldItemView() {
       $item = $this->entity->{$this->field_name}[$delta];
       $build = $item->view($display);
       $this->render($build);
-      $this->assertText($setting . '|0:' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+      $this->assertText($setting . '|0:' . $value['value'], SafeMarkup::format('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
 
     // Check that prepare_view steps are invoked.
@@ -250,7 +251,7 @@ function testFieldItemView() {
       $item = $this->entity->{$this->field_name}[$delta];
       $build = $item->view($display);
       $this->render($build);
-      $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+      $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), SafeMarkup::format('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
 
     // View mode: check that display settings specified in the field are used.
@@ -259,7 +260,7 @@ function testFieldItemView() {
       $item = $this->entity->{$this->field_name}[$delta];
       $build = $item->view('teaser');
       $this->render($build);
-      $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+      $this->assertText($setting . '|' . $value['value'], SafeMarkup::format('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
 
     // Unknown view mode: check that display settings for 'default' view mode
@@ -269,7 +270,7 @@ function testFieldItemView() {
       $item = $this->entity->{$this->field_name}[$delta];
       $build = $item->view('unknown_view_mode');
       $this->render($build);
-      $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+      $this->assertText($setting . '|' . $value['value'], SafeMarkup::format('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
   }
 
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
index 41f3fea..8797746 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests\EntityReference;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\entity_reference\Tests\EntityReferenceTestTrait;
@@ -158,7 +159,7 @@ public function testAccess() {
       entity_view($referencing_entity, 'default');
 
       // Verify the un-accessible item still exists.
-      $this->assertEqual($referencing_entity->{$field_name}->target_id, $this->referencedEntity->id(), format_string('The un-accessible item still exists after @name formatter was executed.', array('@name' => $name)));
+      $this->assertEqual($referencing_entity->{$field_name}->target_id, $this->referencedEntity->id(), SafeMarkup::format('The un-accessible item still exists after @name formatter was executed.', array('@name' => $name)));
     }
   }
 
@@ -168,9 +169,8 @@ public function testAccess() {
   public function testIdFormatter() {
     $formatter = 'entity_reference_entity_id';
     $build = $this->buildRenderArray([$this->referencedEntity, $this->unsavedReferencedEntity], $formatter);
-
-    $this->assertEqual($build[0]['#markup'], $this->referencedEntity->id(), sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
-    $this->assertEqual($build[0]['#cache']['tags'], $this->referencedEntity->getCacheTags(), sprintf('The %s formatter has the expected cache tags.', $formatter));
+    $this->assertEqual($build[0]['#markup'], $this->referencedEntity->id(), SafeMarkup::format('The markup returned by the @formatter formatter is correct.', array('@formatter' => $formatter)));
+    $this->assertEqual($build[0]['#cache']['tags'], $this->referencedEntity->getCacheTags(), SafeMarkup::format('The @formatter formatter has the expected cache tags.', array('@formatter' => $formatter)));
     $this->assertTrue(!isset($build[1]), sprintf('The markup returned by the %s formatter is correct for an item with a unsaved entity.', $formatter));
   }
 
@@ -196,13 +196,13 @@ public function testEntityFormatter() {
 </div>
 ';
     drupal_render($build[0]);
-    $this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() .  $expected_rendered_name_field_1 . $expected_rendered_body_field_1, sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
+    $this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() .  $expected_rendered_name_field_1 . $expected_rendered_body_field_1, SafeMarkup::format('The markup returned by the @formatter formatter is correct.', array('@formatter' => $formatter)));
     $expected_cache_tags = Cache::mergeTags(
       \Drupal::entityManager()->getViewBuilder($this->entityType)->getCacheTags(),
       $this->referencedEntity->getCacheTags(),
       FilterFormat::load('full_html')->getCacheTags()
     );
-    $this->assertEqual($build[0]['#cache']['tags'], $expected_cache_tags, format_string('The @formatter formatter has the expected cache tags.', array('@formatter' => $formatter)));
+    $this->assertEqual($build[0]['#cache']['tags'], $expected_cache_tags, SafeMarkup::format('The @formatter formatter has the expected cache tags.', array('@formatter' => $formatter)));
 
     // Test the second field item.
     drupal_render($build[1]);
diff --git a/core/modules/field/src/Tests/FieldAttachStorageTest.php b/core/modules/field/src/Tests/FieldAttachStorageTest.php
index f51ce1d..0077e9e 100644
--- a/core/modules/field/src/Tests/FieldAttachStorageTest.php
+++ b/core/modules/field/src/Tests/FieldAttachStorageTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\field\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\field\Entity\FieldConfig;
 
@@ -56,17 +57,17 @@ function testFieldAttachSaveLoad() {
     $this->assertEqual(count($entity->{$this->fieldTestData->field_name}), $cardinality, 'Current revision: expected number of values');
     for ($delta = 0; $delta < $cardinality; $delta++) {
       // The field value loaded matches the one inserted or updated.
-      $this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value , $values[$current_revision][$delta]['value'], format_string('Current revision: expected value %delta was found.', array('%delta' => $delta)));
+      $this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value , $values[$current_revision][$delta]['value'], SafeMarkup::format('Current revision: expected value %delta was found.', array('%delta' => $delta)));
     }
 
     // Confirm each revision loads the correct data.
     foreach (array_keys($values) as $revision_id) {
       $entity = $storage->loadRevision($revision_id);
       // Number of values per field loaded equals the field cardinality.
-      $this->assertEqual(count($entity->{$this->fieldTestData->field_name}), $cardinality, format_string('Revision %revision_id: expected number of values.', array('%revision_id' => $revision_id)));
+      $this->assertEqual(count($entity->{$this->fieldTestData->field_name}), $cardinality, SafeMarkup::format('Revision %revision_id: expected number of values.', array('%revision_id' => $revision_id)));
       for ($delta = 0; $delta < $cardinality; $delta++) {
         // The field value loaded matches the one inserted or updated.
-        $this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value, $values[$revision_id][$delta]['value'], format_string('Revision %revision_id: expected value %delta was found.', array('%revision_id' => $revision_id, '%delta' => $delta)));
+        $this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value, $values[$revision_id][$delta]['value'], SafeMarkup::format('Revision %revision_id: expected value %delta was found.', array('%revision_id' => $revision_id, '%delta' => $delta)));
       }
     }
   }
@@ -136,7 +137,7 @@ function testFieldAttachLoadMultiple() {
           continue;
         }
         // The field value loaded matches the one inserted.
-        $this->assertEqual($entity->{$field_name}->value, $values[$index][$field_name], format_string('Entity %index: expected value was found.', array('%index' => $index)));
+        $this->assertEqual($entity->{$field_name}->value, $values[$index][$field_name], SafeMarkup::format('Entity %index: expected value was found.', array('%index' => $index)));
       }
     }
   }
diff --git a/core/modules/field/src/Tests/FieldDataCountTest.php b/core/modules/field/src/Tests/FieldDataCountTest.php
index 2a14652..f720c37 100644
--- a/core/modules/field/src/Tests/FieldDataCountTest.php
+++ b/core/modules/field/src/Tests/FieldDataCountTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
 
 /**
@@ -133,7 +134,7 @@ public function testEntityCountAndHasData() {
 
     $storage =  $this->container->get('entity.manager')->getStorage($entity_type);
     $entity = $storage->loadRevision($first_revision);
-    $this->assertEqual(count($entity->{$this->fieldTestData->field_name_2}), $cardinality, format_string('Revision %revision_id: expected number of values.', array('%revision_id' => $first_revision)));
+    $this->assertEqual(count($entity->{$this->fieldTestData->field_name_2}), $cardinality, SafeMarkup::format('Revision %revision_id: expected number of values.', array('%revision_id' => $first_revision)));
   }
 
 }
diff --git a/core/modules/field/src/Tests/FieldImportDeleteTest.php b/core/modules/field/src/Tests/FieldImportDeleteTest.php
index 04eaecc..58c0716 100644
--- a/core/modules/field/src/Tests/FieldImportDeleteTest.php
+++ b/core/modules/field/src/Tests/FieldImportDeleteTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
@@ -65,11 +66,11 @@ public function testImportDelete() {
     $active = $this->container->get('config.storage');
     $staging = $this->container->get('config.storage.staging');
     $this->copyConfig($active, $staging);
-    $this->assertTrue($staging->delete($field_storage_config_name), String::format('Deleted field storage: !field_storage', array('!field_storage' => $field_storage_config_name)));
-    $this->assertTrue($staging->delete($field_storage_config_name_2), String::format('Deleted field storage: !field_storage', array('!field_storage' => $field_storage_config_name_2)));
-    $this->assertTrue($staging->delete($field_config_name), String::format('Deleted field: !field', array('!field' => $field_config_name)));
-    $this->assertTrue($staging->delete($field_config_name_2a), String::format('Deleted field: !field', array('!field' => $field_config_name_2a)));
-    $this->assertTrue($staging->delete($field_config_name_2b), String::format('Deleted field: !field', array('!field' => $field_config_name_2b)));
+    $this->assertTrue($staging->delete($field_storage_config_name), SafeMarkup::format('Deleted field storage: !field_storage', array('!field_storage' => $field_storage_config_name)));
+    $this->assertTrue($staging->delete($field_storage_config_name_2), SafeMarkup::format('Deleted field storage: !field_storage', array('!field_storage' => $field_storage_config_name_2)));
+    $this->assertTrue($staging->delete($field_config_name), SafeMarkup::format('Deleted field: !field', array('!field' => $field_config_name)));
+    $this->assertTrue($staging->delete($field_config_name_2a), SafeMarkup::format('Deleted field: !field', array('!field' => $field_config_name_2a)));
+    $this->assertTrue($staging->delete($field_config_name_2b), SafeMarkup::format('Deleted field: !field', array('!field' => $field_config_name_2b)));
 
     $deletes = $this->configImporter()->getUnprocessedConfiguration('delete');
     $this->assertEqual(count($deletes), 5, 'Importing configuration will delete 3 fields and 2 field storages.');
diff --git a/core/modules/field/src/Tests/FieldTestBase.php b/core/modules/field/src/Tests/FieldTestBase.php
index d71f152..84ff458 100644
--- a/core/modules/field/src/Tests/FieldTestBase.php
+++ b/core/modules/field/src/Tests/FieldTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\simpletest\WebTestBase;
@@ -60,7 +61,7 @@ function assertFieldValues(EntityInterface $entity, $field_name, $expected_value
     $values = $field->getValue();
     $this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.');
     foreach ($expected_values as $key => $value) {
-      $this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', array('@value' => $value)));
+      $this->assertEqual($values[$key][$column], $value, SafeMarkup::format('Value @value was saved correctly.', array('@value' => $value)));
     }
   }
 }
diff --git a/core/modules/field/src/Tests/FieldTypePluginManagerTest.php b/core/modules/field/src/Tests/FieldTypePluginManagerTest.php
index 758b2f5..7ef99ce 100644
--- a/core/modules/field/src/Tests/FieldTypePluginManagerTest.php
+++ b/core/modules/field/src/Tests/FieldTypePluginManagerTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\field\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 
 use Drupal\Component\Utility\String;
 use Drupal\Core\Field\BaseFieldDefinition;
@@ -25,8 +26,8 @@ function testDefaultSettings() {
     $field_type_manager = \Drupal::service('plugin.manager.field.field_type');
     foreach (array('test_field', 'shape', 'hidden_test_field') as $type) {
       $definition = $field_type_manager->getDefinition($type);
-      $this->assertIdentical($field_type_manager->getDefaultStorageSettings($type), $definition['class']::defaultStorageSettings(), format_string("%type storage settings were returned", array('%type' => $type)));
-      $this->assertIdentical($field_type_manager->getDefaultFieldSettings($type), $definition['class']::defaultFieldSettings(), format_string(" %type field settings were returned", array('%type' => $type)));
+      $this->assertIdentical($field_type_manager->getDefaultStorageSettings($type), $definition['class']::defaultStorageSettings(), SafeMarkup::format("%type storage settings were returned", array('%type' => $type)));
+      $this->assertIdentical($field_type_manager->getDefaultFieldSettings($type), $definition['class']::defaultFieldSettings(), SafeMarkup::format(" %type field settings were returned", array('%type' => $type)));
     }
   }
 
@@ -52,8 +53,8 @@ public function testCreateInstance() {
 
       $instance = $field_type_manager->createInstance($type, $configuration);
 
-      $this->assertTrue($instance instanceof $class, String::format('Created a @class instance', array('@class' => $class)));
-      $this->assertEqual($field_name, $instance->getName(), String::format('Instance name is @name', array('@name' => $field_name)));
+      $this->assertTrue($instance instanceof $class, SafeMarkup::format('Created a @class instance', array('@class' => $class)));
+      $this->assertEqual($field_name, $instance->getName(), SafeMarkup::format('Instance name is @name', array('@name' => $field_name)));
     }
   }
 
@@ -83,8 +84,8 @@ public function testCreateInstanceWithConfig() {
 
     $instance = $field_type_manager->createInstance($type, $configuration);
 
-    $this->assertTrue($instance instanceof $class, String::format('Created a @class instance', array('@class' => $class)));
-    $this->assertEqual($field_name, $instance->getName(), String::format('Instance name is @name', array('@name' => $field_name)));
+    $this->assertTrue($instance instanceof $class, SafeMarkup::format('Created a @class instance', array('@class' => $class)));
+    $this->assertEqual($field_name, $instance->getName(), SafeMarkup::format('Instance name is @name', array('@name' => $field_name)));
     $this->assertEqual($instance->getFieldDefinition()->getLabel(), 'Jenny', 'Instance label is Jenny');
     $this->assertEqual($instance->getFieldDefinition()->getDefaultValue($entity), [['value' => 8675309]], 'Instance default_value is 8675309');
   }
diff --git a/core/modules/field/src/Tests/FieldUnitTestBase.php b/core/modules/field/src/Tests/FieldUnitTestBase.php
index 3c2b535..b411b48 100644
--- a/core/modules/field/src/Tests/FieldUnitTestBase.php
+++ b/core/modules/field/src/Tests/FieldUnitTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Language\LanguageInterface;
@@ -200,7 +201,7 @@ protected function assertFieldValues(EntityInterface $entity, $field_name, $expe
     $values = $field->getValue();
     $this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.');
     foreach ($expected_values as $key => $value) {
-      $this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', array('@value' => $value)));
+      $this->assertEqual($values[$key][$column], $value, SafeMarkup::format('Value @value was saved correctly.', array('@value' => $value)));
     }
   }
 
diff --git a/core/modules/field/src/Tests/String/RawStringFormatterTest.php b/core/modules/field/src/Tests/String/RawStringFormatterTest.php
index bfaad92..d410154 100644
--- a/core/modules/field/src/Tests/String/RawStringFormatterTest.php
+++ b/core/modules/field/src/Tests/String/RawStringFormatterTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests\String;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
@@ -123,7 +124,7 @@ public function testStringFormatter() {
 
     // Verify the cache tags.
     $build = $entity->{$this->fieldName}->view();
-    $this->assertTrue(!isset($build[0]['#cache']), format_string('The string formatter has no cache tags.'));
+    $this->assertTrue(!isset($build[0]['#cache']), SafeMarkup::format('The string formatter has no cache tags.'));
   }
 
 }
diff --git a/core/modules/field/src/Tests/String/StringFieldTest.php b/core/modules/field/src/Tests/String/StringFieldTest.php
index a097ec5..3eb0c1d 100644
--- a/core/modules/field/src/Tests/String/StringFieldTest.php
+++ b/core/modules/field/src/Tests/String/StringFieldTest.php
@@ -9,6 +9,7 @@
 
 use Drupal\Component\Utility\Unicode;
 use Drupal\simpletest\WebTestBase;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests the creation of string fields.
@@ -81,7 +82,7 @@ function _testTextfieldWidgets($field_type, $widget_type) {
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
     $this->assertNoFieldByName("{$field_name}[0][format]", '1', 'Format selector is not displayed');
-    $this->assertRaw(format_string('placeholder="A placeholder on !widget_type"', array('!widget_type' => $widget_type)));
+    $this->assertRaw(SafeMarkup::format('placeholder="A placeholder on !widget_type"', array('!widget_type' => $widget_type)));
 
     // Submit with some value.
     $value = $this->randomMachineName();
diff --git a/core/modules/field/src/Tests/String/StringFormatterTest.php b/core/modules/field/src/Tests/String/StringFormatterTest.php
index bc23148..653fd84 100644
--- a/core/modules/field/src/Tests/String/StringFormatterTest.php
+++ b/core/modules/field/src/Tests/String/StringFormatterTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests\String;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
@@ -123,7 +124,7 @@ public function testStringFormatter() {
 
     // Verify the cache tags.
     $build = $entity->{$this->fieldName}->view();
-    $this->assertTrue(!isset($build[0]['#cache']), format_string('The string formatter has no cache tags.'));
+    $this->assertTrue(!isset($build[0]['#cache']), SafeMarkup::format('The string formatter has no cache tags.'));
 
     // Set the formatter to link to the entity.
     $this->display->setComponent($this->fieldName, [
diff --git a/core/modules/field/src/Tests/TranslationTest.php b/core/modules/field/src/Tests/TranslationTest.php
index 4119b88..783eeb3 100644
--- a/core/modules/field/src/Tests/TranslationTest.php
+++ b/core/modules/field/src/Tests/TranslationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\language\Entity\ConfigurableLanguage;
 
@@ -136,7 +137,7 @@ function testTranslatableFieldSaveLoad() {
       foreach ($items as $delta => $item) {
         $result = $result && $item['value'] == $entity->getTranslation($langcode)->{$this->field_name}[$delta]->value;
       }
-      $this->assertTrue($result, format_string('%language translation correctly handled.', array('%language' => $langcode)));
+      $this->assertTrue($result, SafeMarkup::format('%language translation correctly handled.', array('%language' => $langcode)));
     }
 
     // Test default values.
@@ -170,7 +171,7 @@ function testTranslatableFieldSaveLoad() {
     // @todo Test every translation once the Entity Translation API allows for
     //   multilingual defaults.
     $langcode = $entity->language()->getId();
-    $this->assertEqual($entity->getTranslation($langcode)->{$field_name_default}->getValue(), $field->default_value, format_string('Default value correctly populated for language %language.', array('%language' => $langcode)));
+    $this->assertEqual($entity->getTranslation($langcode)->{$field_name_default}->getValue(), $field->default_value, SafeMarkup::format('Default value correctly populated for language %language.', array('%language' => $langcode)));
 
     // Check that explicit empty values are not overridden with default values.
     foreach (array(NULL, array()) as $empty_items) {
@@ -184,7 +185,7 @@ function testTranslatableFieldSaveLoad() {
       }
 
       foreach ($entity->getTranslationLanguages() as $langcode => $language) {
-        $this->assertEqual($entity->getTranslation($langcode)->{$field_name_default}->getValue(), $empty_items, format_string('Empty value correctly populated for language %language.', array('%language' => $langcode)));
+        $this->assertEqual($entity->getTranslation($langcode)->{$field_name_default}->getValue(), $empty_items, SafeMarkup::format('Empty value correctly populated for language %language.', array('%language' => $langcode)));
       }
     }
   }
diff --git a/core/modules/field/src/Tests/TranslationWebTest.php b/core/modules/field/src/Tests/TranslationWebTest.php
index 34e4be3..d8e445d 100644
--- a/core/modules/field/src/Tests/TranslationWebTest.php
+++ b/core/modules/field/src/Tests/TranslationWebTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\field\Entity\FieldConfig;
@@ -129,7 +130,7 @@ private function checkTranslationRevisions($id, $revision_id, $available_langcod
     $entity = entity_revision_load($this->entity_type, $revision_id);
     foreach ($available_langcodes as $langcode => $value) {
       $passed = $entity->getTranslation($langcode)->{$field_name}->value == $value + 1;
-      $this->assertTrue($passed, format_string('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->getRevisionId())));
+      $this->assertTrue($passed, SafeMarkup::format('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->getRevisionId())));
     }
   }
 }
diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php
index 28b80ae..c0828c0 100644
--- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php
+++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field_ui\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\Language\LanguageInterface;
@@ -144,7 +145,7 @@ function manageFieldsPage($type = '') {
     );
     foreach ($table_headers as $table_header) {
       // We check that the label appear in the table headings.
-      $this->assertRaw($table_header . '</th>', format_string('%table_header table header was found.', array('%table_header' => $table_header)));
+      $this->assertRaw($table_header . '</th>', SafeMarkup::format('%table_header table header was found.', array('%table_header' => $table_header)));
     }
 
     // Test the "Add field" action link.
@@ -357,7 +358,7 @@ function testFieldPrefix() {
     // Create a valid field.
     $this->fieldUIAddNewField('admin/structure/types/manage/' . $this->contentType, $this->fieldNameInput, $this->fieldLabel);
     $this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/node.' . $this->contentType . '.' . $field_prefix . $this->fieldNameInput);
-    $this->assertText(format_string('@label settings for @type', array('@label' => $this->fieldLabel, '@type' => $this->contentType)));
+    $this->assertText(SafeMarkup::format('@label settings for @type', array('@label' => $this->fieldLabel, '@type' => $this->contentType)));
   }
 
   /**
@@ -559,7 +560,7 @@ function testHiddenFields() {
     entity_get_form_display('node', $this->contentType, 'default')
       ->setComponent($field_name)
       ->save();
-    $this->assertTrue(FieldConfig::load('node.' . $this->contentType . '.' . $field_name), format_string('A field of the field storage %field was created programmatically.', array('%field' => $field_name)));
+    $this->assertTrue(FieldConfig::load('node.' . $this->contentType . '.' . $field_name), SafeMarkup::format('A field of the field storage %field was created programmatically.', array('%field' => $field_name)));
 
     // Check that the newly added field appears on the 'Manage Fields'
     // screen.
@@ -576,10 +577,10 @@ function testHiddenFields() {
     $field_types = \Drupal::service('plugin.manager.field.field_type')->getDefinitions();
     foreach ($field_types as $field_type => $definition) {
       if (empty($definition['no_ui'])) {
-        $this->assertTrue($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', array(':field_type' => $field_type)), String::format('Configurable field type @field_type is available.', array('@field_type' => $field_type)));
+        $this->assertTrue($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', array(':field_type' => $field_type)), SafeMarkup::format('Configurable field type @field_type is available.', array('@field_type' => $field_type)));
       }
       else {
-        $this->assertFalse($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', array(':field_type' => $field_type)), String::format('Non-configurable field type @field_type is not available.', array('@field_type' => $field_type)));
+        $this->assertFalse($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', array(':field_type' => $field_type)), SafeMarkup::format('Non-configurable field type @field_type is not available.', array('@field_type' => $field_type)));
       }
     }
   }
diff --git a/core/modules/file/src/Tests/FileFieldDisplayTest.php b/core/modules/file/src/Tests/FileFieldDisplayTest.php
index f1a3f8a..8bb6b81 100644
--- a/core/modules/file/src/Tests/FileFieldDisplayTest.php
+++ b/core/modules/file/src/Tests/FileFieldDisplayTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\file\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 
 /**
@@ -45,7 +46,7 @@ function testNodeDisplay() {
       );
       $this->drupalPostForm("admin/structure/types/manage/$type_name/display", $edit, t('Save'));
       $this->drupalGet('node/' . $node->id());
-      $this->assertNoText($field_name, format_string('Field label is hidden when no file attached for formatter %formatter', array('%formatter' => $formatter)));
+      $this->assertNoText($field_name, SafeMarkup::format('Field label is hidden when no file attached for formatter %formatter', array('%formatter' => $formatter)));
     }
 
     $test_file = $this->getTestFile('text');
diff --git a/core/modules/file/src/Tests/FileFieldPathTest.php b/core/modules/file/src/Tests/FileFieldPathTest.php
index 6de342a..f18af58 100644
--- a/core/modules/file/src/Tests/FileFieldPathTest.php
+++ b/core/modules/file/src/Tests/FileFieldPathTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\file\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests that files are uploaded to proper locations.
@@ -30,7 +31,7 @@ function testUploadPath() {
     $node_storage->resetCache(array($nid));
     $node = $node_storage->load($nid);
     $node_file = file_load($node->{$field_name}->target_id);
-    $this->assertPathMatch('public://' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri())));
+    $this->assertPathMatch('public://' . $test_file->getFilename(), $node_file->getFileUri(), SafeMarkup::format('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri())));
 
     // Change the path to contain multiple subdirectories.
     $this->updateFileField($field_name, $type_name, array('file_directory' => 'foo/bar/baz'));
@@ -42,7 +43,7 @@ function testUploadPath() {
     $node_storage->resetCache(array($nid));
     $node = $node_storage->load($nid);
     $node_file = file_load($node->{$field_name}->target_id, TRUE);
-    $this->assertPathMatch('public://foo/bar/baz/' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri())));
+    $this->assertPathMatch('public://foo/bar/baz/' . $test_file->getFilename(), $node_file->getFileUri(), SafeMarkup::format('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri())));
 
     // Check the path when used with tokens.
     // Change the path to contain multiple token directories.
@@ -59,7 +60,7 @@ function testUploadPath() {
     // the user running the test case.
     $data = array('user' => $this->adminUser);
     $subdirectory = \Drupal::token()->replace('[user:uid]/[user:name]', $data);
-    $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->getFileUri())));
+    $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->getFilename(), $node_file->getFileUri(), SafeMarkup::format('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->getFileUri())));
   }
 
   /**
diff --git a/core/modules/file/src/Tests/FileFieldTestBase.php b/core/modules/file/src/Tests/FileFieldTestBase.php
index 25ef7f2..aac069c 100644
--- a/core/modules/file/src/Tests/FileFieldTestBase.php
+++ b/core/modules/file/src/Tests/FileFieldTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\file\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\file\FileInterface;
@@ -212,7 +213,7 @@ function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) {
    * Asserts that a file exists physically on disk.
    */
   function assertFileExists($file, $message = NULL) {
-    $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri()));
+    $message = isset($message) ? $message : SafeMarkup::format('File %file exists on the disk.', array('%file' => $file->getFileUri()));
     $this->assertTrue(is_file($file->getFileUri()), $message);
   }
 
@@ -222,7 +223,7 @@ function assertFileExists($file, $message = NULL) {
   function assertFileEntryExists($file, $message = NULL) {
     $this->container->get('entity.manager')->getStorage('file')->resetCache();
     $db_file = file_load($file->id());
-    $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri()));
+    $message = isset($message) ? $message : SafeMarkup::format('File %file exists in database at the correct path.', array('%file' => $file->getFileUri()));
     $this->assertEqual($db_file->getFileUri(), $file->getFileUri(), $message);
   }
 
@@ -230,7 +231,7 @@ function assertFileEntryExists($file, $message = NULL) {
    * Asserts that a file does not exist on disk.
    */
   function assertFileNotExists($file, $message = NULL) {
-    $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri()));
+    $message = isset($message) ? $message : SafeMarkup::format('File %file exists on the disk.', array('%file' => $file->getFileUri()));
     $this->assertFalse(is_file($file->getFileUri()), $message);
   }
 
@@ -239,7 +240,7 @@ function assertFileNotExists($file, $message = NULL) {
    */
   function assertFileEntryNotExists($file, $message) {
     $this->container->get('entity.manager')->getStorage('file')->resetCache();
-    $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri()));
+    $message = isset($message) ? $message : SafeMarkup::format('File %file exists in database at the correct path.', array('%file' => $file->getFileUri()));
     $this->assertFalse(file_load($file->id()), $message);
   }
 
@@ -247,7 +248,7 @@ function assertFileEntryNotExists($file, $message) {
    * Asserts that a file's status is set to permanent in the database.
    */
   function assertFileIsPermanent(FileInterface $file, $message = NULL) {
-    $message = isset($message) ? $message : format_string('File %file is permanent.', array('%file' => $file->getFileUri()));
+    $message = isset($message) ? $message : SafeMarkup::format('File %file is permanent.', array('%file' => $file->getFileUri()));
     $this->assertTrue($file->isPermanent(), $message);
   }
 
diff --git a/core/modules/file/src/Tests/FileFieldValidateTest.php b/core/modules/file/src/Tests/FileFieldValidateTest.php
index 51d7402..11c8c46 100644
--- a/core/modules/file/src/Tests/FileFieldValidateTest.php
+++ b/core/modules/file/src/Tests/FileFieldValidateTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\file\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\field\Entity\FieldConfig;
 
@@ -38,7 +39,7 @@ function testRequired() {
 
     // Create a new node with the uploaded file.
     $nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
-    $this->assertTrue($nid !== FALSE, format_string('uploadNodeFile(@test_file, @field_name, @type_name) succeeded', array('@test_file' => $test_file->getFileUri(), '@field_name' => $field_name, '@type_name' => $type_name)));
+    $this->assertTrue($nid !== FALSE, SafeMarkup::format('uploadNodeFile(@test_file, @field_name, @type_name) succeeded', array('@test_file' => $test_file->getFileUri(), '@field_name' => $field_name, '@type_name' => $type_name)));
 
     $node_storage->resetCache(array($nid));
     $node = $node_storage->load($nid);
@@ -94,13 +95,13 @@ function testFileMaxSize() {
       $node_storage->resetCache(array($nid));
       $node = $node_storage->load($nid);
       $node_file = file_load($node->{$field_name}->target_id);
-      $this->assertFileExists($node_file, format_string('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->getSize()), '%maxsize' => $max_filesize)));
-      $this->assertFileEntryExists($node_file, format_string('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->getSize()), '%maxsize' => $max_filesize)));
+      $this->assertFileExists($node_file, SafeMarkup::format('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->getSize()), '%maxsize' => $max_filesize)));
+      $this->assertFileEntryExists($node_file, SafeMarkup::format('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->getSize()), '%maxsize' => $max_filesize)));
 
       // Check that uploading the large file fails (1M limit).
       $this->uploadNodeFile($large_file, $field_name, $type_name);
       $error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($large_file->getSize()), '%maxsize' => format_size($file_limit)));
-      $this->assertRaw($error_message, format_string('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', array('%filesize' => format_size($large_file->getSize()), '%maxsize' => $max_filesize)));
+      $this->assertRaw($error_message, SafeMarkup::format('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', array('%filesize' => format_size($large_file->getSize()), '%maxsize' => $max_filesize)));
     }
 
     // Turn off the max filesize.
@@ -111,8 +112,8 @@ function testFileMaxSize() {
     $node_storage->resetCache(array($nid));
     $node = $node_storage->load($nid);
     $node_file = file_load($node->{$field_name}->target_id);
-    $this->assertFileExists($node_file, format_string('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->getSize()))));
-    $this->assertFileEntryExists($node_file, format_string('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->getSize()))));
+    $this->assertFileExists($node_file, SafeMarkup::format('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->getSize()))));
+    $this->assertFileEntryExists($node_file, SafeMarkup::format('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->getSize()))));
   }
 
   /**
diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php
index 8ebb696..210fd25 100644
--- a/core/modules/file/src/Tests/FileFieldWidgetTest.php
+++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php
@@ -10,6 +10,7 @@
 use Drupal\comment\Entity\Comment;
 use Drupal\comment\Tests\CommentTestTrait;
 use Drupal\Component\Utility\Html;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field_ui\Tests\FieldUiTestTrait;
 use Drupal\user\RoleInterface;
@@ -151,7 +152,7 @@ function testMultiValuedWidget() {
           // Ensure we have the expected number of Remove buttons, and that they
           // are numbered sequentially.
           $buttons = $this->xpath('//input[@type="submit" and @value="Remove"]');
-          $this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, format_string('There are %n "Remove" buttons displayed (JSMode=%type).', array('%n' => $num_expected_remove_buttons, '%type' => $type)));
+          $this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, SafeMarkup::format('There are %n "Remove" buttons displayed (JSMode=%type).', array('%n' => $num_expected_remove_buttons, '%type' => $type)));
           foreach ($buttons as $i => $button) {
             $key = $i >= $remaining ? $i - $remaining : $i;
             $check_field_name = $field_name2;
@@ -193,17 +194,17 @@ function testMultiValuedWidget() {
           // correct name.
           $upload_button_name = $current_field_name . '_' . $remaining . '_upload_button';
           $buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', array(':name' => $upload_button_name));
-          $this->assertTrue(is_array($buttons) && count($buttons) == 1, format_string('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type)));
+          $this->assertTrue(is_array($buttons) && count($buttons) == 1, SafeMarkup::format('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type)));
 
           // Ensure only at most one button per field is displayed.
           $buttons = $this->xpath('//input[@type="submit" and @value="Upload"]');
           $expected = $current_field_name == $field_name ? 1 : 2;
-          $this->assertTrue(is_array($buttons) && count($buttons) == $expected, format_string('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', array('%type' => $type)));
+          $this->assertTrue(is_array($buttons) && count($buttons) == $expected, SafeMarkup::format('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', array('%type' => $type)));
         }
       }
 
       // Ensure the page now has no Remove buttons.
-      $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), format_string('After removing all files, there is no "Remove" button displayed (JSMode=%type).', array('%type' => $type)));
+      $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), SafeMarkup::format('After removing all files, there is no "Remove" button displayed (JSMode=%type).', array('%type' => $type)));
 
       // Save the node and ensure it does not have any files.
       $this->drupalPostForm(NULL, array('title[0][value]' => $this->randomMachineName()), t('Save and publish'));
diff --git a/core/modules/file/src/Tests/FileManagedTestBase.php b/core/modules/file/src/Tests/FileManagedTestBase.php
index 031a1a7..7ee4db0 100644
--- a/core/modules/file/src/Tests/FileManagedTestBase.php
+++ b/core/modules/file/src/Tests/FileManagedTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\file\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\file\FileInterface;
 use Drupal\simpletest\WebTestBase;
 
@@ -46,16 +47,16 @@ function assertFileHooksCalled($expected) {
     // Determine if there were any expected that were not called.
     $uncalled = array_diff($expected, $actual);
     if (count($uncalled)) {
-      $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
+      $this->assertTrue(FALSE, SafeMarkup::format('Expected hooks %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
     }
     else {
-      $this->assertTrue(TRUE, format_string('All the expected hooks were called: %expected', array('%expected' => empty($expected) ? '(none)' : implode(', ', $expected))));
+      $this->assertTrue(TRUE, SafeMarkup::format('All the expected hooks were called: %expected', array('%expected' => empty($expected) ? '(none)' : implode(', ', $expected))));
     }
 
     // Determine if there were any unexpected calls.
     $unexpected = array_diff($actual, $expected);
     if (count($unexpected)) {
-      $this->assertTrue(FALSE, format_string('Unexpected hooks were called: %unexpected.', array('%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected))));
+      $this->assertTrue(FALSE, SafeMarkup::format('Unexpected hooks were called: %unexpected.', array('%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected))));
     }
     else {
       $this->assertTrue(TRUE, 'No unexpected hooks were called.');
@@ -77,13 +78,13 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) {
 
     if (!isset($message)) {
       if ($actual_count == $expected_count) {
-        $message = format_string('hook_file_@name was called correctly.', array('@name' => $hook));
+        $message = SafeMarkup::format('hook_file_@name was called correctly.', array('@name' => $hook));
       }
       elseif ($expected_count == 0) {
         $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count));
       }
       else {
-        $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count));
+        $message = SafeMarkup::format('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count));
       }
     }
     $this->assertEqual($actual_count, $expected_count, $message);
diff --git a/core/modules/file/src/Tests/FileManagedUnitTestBase.php b/core/modules/file/src/Tests/FileManagedUnitTestBase.php
index 00448c5..e33a00a2 100644
--- a/core/modules/file/src/Tests/FileManagedUnitTestBase.php
+++ b/core/modules/file/src/Tests/FileManagedUnitTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\file\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\file\FileInterface;
 use Drupal\simpletest\KernelTestBase;
 
@@ -58,16 +59,16 @@ function assertFileHooksCalled($expected) {
     // Determine if there were any expected that were not called.
     $uncalled = array_diff($expected, $actual);
     if (count($uncalled)) {
-      $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
+      $this->assertTrue(FALSE, SafeMarkup::format('Expected hooks %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
     }
     else {
-      $this->assertTrue(TRUE, format_string('All the expected hooks were called: %expected', array('%expected' => empty($expected) ? '(none)' : implode(', ', $expected))));
+      $this->assertTrue(TRUE, SafeMarkup::format('All the expected hooks were called: %expected', array('%expected' => empty($expected) ? '(none)' : implode(', ', $expected))));
     }
 
     // Determine if there were any unexpected calls.
     $unexpected = array_diff($actual, $expected);
     if (count($unexpected)) {
-      $this->assertTrue(FALSE, format_string('Unexpected hooks were called: %unexpected.', array('%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected))));
+      $this->assertTrue(FALSE, SafeMarkup::format('Unexpected hooks were called: %unexpected.', array('%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected))));
     }
     else {
       $this->assertTrue(TRUE, 'No unexpected hooks were called.');
@@ -89,13 +90,13 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) {
 
     if (!isset($message)) {
       if ($actual_count == $expected_count) {
-        $message = format_string('hook_file_@name was called correctly.', array('@name' => $hook));
+        $message = SafeMarkup::format('hook_file_@name was called correctly.', array('@name' => $hook));
       }
       elseif ($expected_count == 0) {
         $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count));
       }
       else {
-        $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count));
+        $message = SafeMarkup::format('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count));
       }
     }
     $this->assertEqual($actual_count, $expected_count, $message);
diff --git a/core/modules/file/src/Tests/FilePrivateTest.php b/core/modules/file/src/Tests/FilePrivateTest.php
index 9c7762b..e152dbc 100644
--- a/core/modules/file/src/Tests/FilePrivateTest.php
+++ b/core/modules/file/src/Tests/FilePrivateTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\file\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\Plugin\Validation\Constraint\ReferenceAccessConstraint;
 use Drupal\Component\Utility\String;
 use Drupal\file\Entity\File;
@@ -83,7 +84,7 @@ function testPrivateFile() {
     $this->assertUrl('node/' . $new_node->id() .'/edit');
     // Check that we got the expected constraint form error.
     $constraint = new ReferenceAccessConstraint();
-    $this->assertRaw(String::format($constraint->message, array('%type' => 'file', '%id' => $node_file->id())));
+    $this->assertRaw(SafeMarkup::format($constraint->message, array('%type' => 'file', '%id' => $node_file->id())));
     // Attempt to reuse the existing file when creating a new node, and confirm
     // that access is still denied.
     $edit = array();
@@ -93,6 +94,6 @@ function testPrivateFile() {
     $new_node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
     $this->assertTrue(empty($new_node), 'Node was not created.');
     $this->assertUrl('node/add/' . $type_name);
-    $this->assertRaw(String::format($constraint->message, array('%type' => 'file', '%id' => $node_file->id())));
+    $this->assertRaw(SafeMarkup::format($constraint->message, array('%type' => 'file', '%id' => $node_file->id())));
   }
 }
diff --git a/core/modules/file/src/Tests/FileTokenReplaceTest.php b/core/modules/file/src/Tests/FileTokenReplaceTest.php
index bc53e68..9523cab 100644
--- a/core/modules/file/src/Tests/FileTokenReplaceTest.php
+++ b/core/modules/file/src/Tests/FileTokenReplaceTest.php
@@ -62,7 +62,7 @@ function testFileTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId()));
-      $this->assertEqual($output, $expected, format_string('Sanitized file token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Sanitized file token %token replaced.', array('%token' => $input)));
     }
 
     // Generate and test unsanitized tokens.
@@ -73,7 +73,7 @@ function testFileTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE));
-      $this->assertEqual($output, $expected, format_string('Unsanitized file token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Unsanitized file token %token replaced.', array('%token' => $input)));
     }
   }
 }
diff --git a/core/modules/file/src/Tests/MoveTest.php b/core/modules/file/src/Tests/MoveTest.php
index 9b1bfc2..0795cb9 100644
--- a/core/modules/file/src/Tests/MoveTest.php
+++ b/core/modules/file/src/Tests/MoveTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\file\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests the file move function.
@@ -34,7 +35,7 @@ function testNormal() {
     $this->assertFileHooksCalled(array('move', 'load', 'update'));
 
     // Make sure we got the same file back.
-    $this->assertEqual($source->id(), $result->id(), format_string("Source file id's' %fid is unchanged after move.", array('%fid' => $source->id())));
+    $this->assertEqual($source->id(), $result->id(), SafeMarkup::format("Source file id's' %fid is unchanged after move.", array('%fid' => $source->id())));
 
     // Reload the file from the database and check that the changes were
     // actually saved.
diff --git a/core/modules/filter/src/Tests/FilterAPITest.php b/core/modules/filter/src/Tests/FilterAPITest.php
index fe54ccd..38340da 100644
--- a/core/modules/filter/src/Tests/FilterAPITest.php
+++ b/core/modules/filter/src/Tests/FilterAPITest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\filter\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Core\Session\AnonymousUserSession;
@@ -396,7 +397,7 @@ public function assertFilterFormatViolation(ConstraintViolationListInterface $vi
         break;
       }
     }
-    $this->assertTrue($filter_format_violation_found, format_string('Validation violation for invalid value "%invalid_value" found', array('%invalid_value' => $invalid_value)));
+    $this->assertTrue($filter_format_violation_found, SafeMarkup::format('Validation violation for invalid value "%invalid_value" found', array('%invalid_value' => $invalid_value)));
   }
 
   /**
@@ -424,7 +425,7 @@ public function testDependencyRemoval() {
 
     $module_data = _system_rebuild_module_data();
     $this->assertTrue($module_data['filter_test']->info['required'], 'The filter_test module is required.');
-    $this->assertEqual($module_data['filter_test']->info['explanation'], String::format('Provides a filter plugin that is in use in the following filter formats: %formats', array('%formats' => $filter_format->label())));
+    $this->assertEqual($module_data['filter_test']->info['explanation'], SafeMarkup::format('Provides a filter plugin that is in use in the following filter formats: %formats', array('%formats' => $filter_format->label())));
 
     // Disable the filter_test_restrict_tags_and_attributes filter plugin but
     // have custom configuration so that the filter plugin is still configured
diff --git a/core/modules/filter/src/Tests/FilterAdminTest.php b/core/modules/filter/src/Tests/FilterAdminTest.php
index b964e71..c411cc0 100644
--- a/core/modules/filter/src/Tests/FilterAdminTest.php
+++ b/core/modules/filter/src/Tests/FilterAdminTest.php
@@ -142,7 +142,7 @@ function testFormatAdmin() {
     $edit_link = $this->xpath('//a[@href=:href]', array(
       ':href' => \Drupal::url('entity.filter_format.edit_form', ['filter_format' => $format_id])
     ));
-    $this->assertTrue($edit_link, format_string('Link href %href found.',
+    $this->assertTrue($edit_link, SafeMarkup::format('Link href %href found.',
       array('%href' => 'admin/config/content/formats/manage/' . $format_id)
     ));
     $this->drupalGet('admin/config/content/formats/manage/' . $format_id);
diff --git a/core/modules/filter/src/Tests/FilterCrudTest.php b/core/modules/filter/src/Tests/FilterCrudTest.php
index a64c28f..170f605 100644
--- a/core/modules/filter/src/Tests/FilterCrudTest.php
+++ b/core/modules/filter/src/Tests/FilterCrudTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\filter\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\KernelTestBase;
 
 /**
@@ -82,11 +83,11 @@ function verifyTextFormat($format) {
 
     // Verify the loaded filter has all properties.
     $filter_format = entity_load('filter_format', $format->id());
-    $this->assertEqual($filter_format->id(), $format->id(), format_string('filter_format_load: Proper format id for text format %format.', $t_args));
-    $this->assertEqual($filter_format->label(), $format->label(), format_string('filter_format_load: Proper title for text format %format.', $t_args));
-    $this->assertEqual($filter_format->get('weight'), $format->get('weight'), format_string('filter_format_load: Proper weight for text format %format.', $t_args));
+    $this->assertEqual($filter_format->id(), $format->id(), SafeMarkup::format('filter_format_load: Proper format id for text format %format.', $t_args));
+    $this->assertEqual($filter_format->label(), $format->label(), SafeMarkup::format('filter_format_load: Proper title for text format %format.', $t_args));
+    $this->assertEqual($filter_format->get('weight'), $format->get('weight'), SafeMarkup::format('filter_format_load: Proper weight for text format %format.', $t_args));
     // Check that the filter was created in site default language.
-    $this->assertEqual($format->language()->getId(), $default_langcode, format_string('filter_format_load: Proper language code for text format %format.', $t_args));
+    $this->assertEqual($format->language()->getId(), $default_langcode, SafeMarkup::format('filter_format_load: Proper language code for text format %format.', $t_args));
   }
 
 }
diff --git a/core/modules/filter/src/Tests/FilterFormTest.php b/core/modules/filter/src/Tests/FilterFormTest.php
index 7db7c0f..0e66080 100644
--- a/core/modules/filter/src/Tests/FilterFormTest.php
+++ b/core/modules/filter/src/Tests/FilterFormTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\filter\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\simpletest\WebTestBase;
 
@@ -183,7 +184,7 @@ protected function doFilterFormTestAsNonAdmin() {
    */
   protected function assertNoSelect($id) {
     $select = $this->xpath('//select[@id=:id]', array(':id' => $id));
-    return $this->assertFalse($select, String::format('Field @id does not exist.', array(
+    return $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', array(
       '@id' => $id,
     )));
   }
@@ -204,7 +205,7 @@ protected function assertNoSelect($id) {
   protected function assertOptions($id, array $expected_options, $selected) {
     $select = $this->xpath('//select[@id=:id]', array(':id' => $id));
     $select = reset($select);
-    $passed = $this->assertTrue($select instanceof \SimpleXMLElement, String::format('Field @id exists.', array(
+    $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Field @id exists.', array(
       '@id' => $id,
     )));
 
@@ -212,7 +213,7 @@ protected function assertOptions($id, array $expected_options, $selected) {
     foreach ($found_options as $found_key => $found_option) {
       $expected_key = array_search($found_option->attributes()->value, $expected_options);
       if ($expected_key !== FALSE) {
-        $this->pass(String::format('Option @option for field @id exists.', array(
+        $this->pass(SafeMarkup::format('Option @option for field @id exists.', array(
           '@option' => $expected_options[$expected_key],
           '@id' => $id,
         )));
@@ -224,14 +225,14 @@ protected function assertOptions($id, array $expected_options, $selected) {
     // Make sure that all expected options were found and that there are no
     // unexpected options.
     foreach ($expected_options as $expected_option) {
-      $this->fail(String::format('Option @option for field @id exists.', array(
+      $this->fail(SafeMarkup::format('Option @option for field @id exists.', array(
         '@option' => $expected_option,
         '@id' => $id,
       )));
       $passed = FALSE;
     }
     foreach ($found_options as $found_option) {
-      $this->fail(String::format('Option @option for field @id does not exist.', array(
+      $this->fail(SafeMarkup::format('Option @option for field @id does not exist.', array(
         '@option' => $found_option->attributes()->value,
         '@id' => $id,
       )));
@@ -258,7 +259,7 @@ protected function assertRequiredSelectAndOptions($id, array $options) {
       ':id' => $id,
     ));
     $select = reset($select);
-    $passed = $this->assertTrue($select instanceof \SimpleXMLElement, String::format('Required field @id exists.', array(
+    $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Required field @id exists.', array(
       '@id' => $id,
     )));
     // A required select element has a "- Select -" option whose key is an empty
@@ -281,7 +282,7 @@ protected function assertEnabledTextarea($id) {
       ':id' => $id,
     ));
     $textarea = reset($textarea);
-    return $this->assertTrue($textarea instanceof \SimpleXMLElement, String::format('Enabled field @id exists.', array(
+    return $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Enabled field @id exists.', array(
       '@id' => $id,
     )));
   }
@@ -300,11 +301,11 @@ protected function assertDisabledTextarea($id) {
       ':id' => $id,
     ));
     $textarea = reset($textarea);
-    $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, String::format('Disabled field @id exists.', array(
+    $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', array(
       '@id' => $id,
     )));
     $expected = 'This field has been disabled because you do not have sufficient permissions to edit it.';
-    $passed = $passed && $this->assertEqual((string) $textarea, $expected, String::format('Disabled textarea @id hides text in an inaccessible text format.', array(
+    $passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', array(
       '@id' => $id,
     )));
     // Make sure the text format select is not shown.
diff --git a/core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php b/core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php
index df860f2..7b2ee61 100644
--- a/core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php
+++ b/core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\filter\Tests;
 
 use Drupal\comment\Tests\CommentTestTrait;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\StreamWrapper\PublicStream;
 use Drupal\simpletest\WebTestBase;
 
@@ -155,7 +156,7 @@ function testImageSource() {
           $this->assertEqual((string) $element['src'], $converted);
         }
       }
-      $this->assertTrue($found, format_string('@image was found.', array('@image' => $image)));
+      $this->assertTrue($found, SafeMarkup::format('@image was found.', array('@image' => $image)));
     }
   }
 }
diff --git a/core/modules/filter/src/Tests/FilterSettingsTest.php b/core/modules/filter/src/Tests/FilterSettingsTest.php
index b88fcec..30167ac 100644
--- a/core/modules/filter/src/Tests/FilterSettingsTest.php
+++ b/core/modules/filter/src/Tests/FilterSettingsTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\filter\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\KernelTestBase;
 
 /**
@@ -40,7 +41,7 @@ function testFilterDefaults() {
     $saved_settings = array();
     foreach ($filter_defaults_format->filters() as $name => $filter) {
       $expected_weight = $filter_info[$name]['weight'];
-      $this->assertEqual($filter->weight, $expected_weight, format_string('@name filter weight %saved equals %default', array(
+      $this->assertEqual($filter->weight, $expected_weight, SafeMarkup::format('@name filter weight %saved equals %default', array(
         '@name' => $name,
         '%saved' => $filter->weight,
         '%default' => $expected_weight,
@@ -55,7 +56,7 @@ function testFilterDefaults() {
 
     // Verify that saved filter settings have not been changed.
     foreach ($filter_defaults_format->filters() as $name => $filter) {
-      $this->assertEqual($filter->weight, $saved_settings[$name]['weight'], format_string('@name filter weight %saved equals %previous', array(
+      $this->assertEqual($filter->weight, $saved_settings[$name]['weight'], SafeMarkup::format('@name filter weight %saved equals %previous', array(
         '@name' => $name,
         '%saved' => $filter->weight,
         '%previous' => $saved_settings[$name]['weight'],
diff --git a/core/modules/filter/src/Tests/FilterUnitTest.php b/core/modules/filter/src/Tests/FilterUnitTest.php
index 2c2a5c9..a561263 100644
--- a/core/modules/filter/src/Tests/FilterUnitTest.php
+++ b/core/modules/filter/src/Tests/FilterUnitTest.php
@@ -753,14 +753,14 @@ function assertFilteredString($filter, $tests) {
       foreach ($tasks as $value => $is_expected) {
         // Not using assertIdentical, since combination with strpos() is hard to grok.
         if ($is_expected) {
-          $success = $this->assertTrue(strpos($result, $value) !== FALSE, format_string('@source: @value found. Filtered result: @result.', array(
+          $success = $this->assertTrue(strpos($result, $value) !== FALSE, SafeMarkup::format('@source: @value found. Filtered result: @result.', array(
             '@source' => var_export($source, TRUE),
             '@value' => var_export($value, TRUE),
             '@result' => var_export($result, TRUE),
           )));
         }
         else {
-          $success = $this->assertTrue(strpos($result, $value) === FALSE, format_string('@source: @value not found. Filtered result: @result.', array(
+          $success = $this->assertTrue(strpos($result, $value) === FALSE, SafeMarkup::format('@source: @value not found. Filtered result: @result.', array(
             '@source' => var_export($source, TRUE),
             '@value' => var_export($value, TRUE),
             '@result' => var_export($result, TRUE),
@@ -943,7 +943,7 @@ function testHtmlCorrectorFilter() {
 
 /*--><!]]>*/
 </style></p>',
-      format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '/*<![CDATA[*/'))
+      SafeMarkup::format('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '/*<![CDATA[*/'))
     );
 
     $filtered_data = Html::normalize('<p><style>
@@ -962,7 +962,7 @@ function testHtmlCorrectorFilter() {
 
 /*--><!]]>*/
 </style></p>',
-      format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '<!--/*--><![CDATA[/* ><!--*/'))
+      SafeMarkup::format('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '<!--/*--><![CDATA[/* ><!--*/'))
     );
 
     $filtered_data = Html::normalize('<p><script>
@@ -979,7 +979,7 @@ function testHtmlCorrectorFilter() {
 
 //--><!]]>
 </script></p>',
-      format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '<!--//--><![CDATA[// ><!--'))
+      SafeMarkup::format('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '<!--//--><![CDATA[// ><!--'))
     );
 
     $filtered_data = Html::normalize('<p><script>
@@ -996,7 +996,7 @@ function testHtmlCorrectorFilter() {
 
 //--><!]]>
 </script></p>',
-      format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '// <![CDATA['))
+      SafeMarkup::format('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '// <![CDATA['))
     );
 
   }
diff --git a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestPostRenderCache.php b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestPostRenderCache.php
index aaeb400..c3b6e4c 100644
--- a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestPostRenderCache.php
+++ b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestPostRenderCache.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\filter_test\Plugin\Filter;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\filter\FilterProcessResult;
 use Drupal\filter\Plugin\FilterBase;
 
@@ -51,7 +52,7 @@ public function process($text, $langcode) {
   public static function renderDynamicThing(array $element, array $context) {
     $callback = '\Drupal\filter_test\Plugin\Filter\FilterTestPostRenderCache::renderDynamicThing';
     $placeholder = drupal_render_cache_generate_placeholder($callback, $context);
-    $markup = format_string('This is a dynamic @thing.', array('@thing' => $context['thing']));
+    $markup = SafeMarkup::format('This is a dynamic @thing.', array('@thing' => $context['thing']));
     $element['#markup'] = str_replace($placeholder, $markup, $element['#markup']);
     return $element;
   }
diff --git a/core/modules/forum/src/Tests/ForumBlockTest.php b/core/modules/forum/src/Tests/ForumBlockTest.php
index 78e1c44..b05bf20 100644
--- a/core/modules/forum/src/Tests/ForumBlockTest.php
+++ b/core/modules/forum/src/Tests/ForumBlockTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\forum\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 use Drupal\Core\Datetime\DrupalDateTime;
 
@@ -62,7 +63,7 @@ public function testNewForumTopicsBlock() {
 
     // We expect all 5 forum topics to appear in the "New forum topics" block.
     foreach ($topics as $topic) {
-      $this->assertLink($topic, 0, format_string('Forum topic @topic found in the "New forum topics" block.', array('@topic' => $topic)));
+      $this->assertLink($topic, 0, SafeMarkup::format('Forum topic @topic found in the "New forum topics" block.', array('@topic' => $topic)));
     }
 
     // Configure the new forum topics block to only show 2 topics.
@@ -74,10 +75,10 @@ public function testNewForumTopicsBlock() {
     // topics" block.
     for ($index = 0; $index < 5; $index++) {
       if (in_array($index, array(3, 4))) {
-        $this->assertLink($topics[$index], 0, format_string('Forum topic @topic found in the "New forum topics" block.', array('@topic' => $topics[$index])));
+        $this->assertLink($topics[$index], 0, SafeMarkup::format('Forum topic @topic found in the "New forum topics" block.', array('@topic' => $topics[$index])));
       }
       else {
-        $this->assertNoText($topics[$index], format_string('Forum topic @topic not found in the "New forum topics" block.', array('@topic' => $topics[$index])));
+        $this->assertNoText($topics[$index], SafeMarkup::format('Forum topic @topic not found in the "New forum topics" block.', array('@topic' => $topics[$index])));
       }
     }
   }
@@ -120,10 +121,10 @@ public function testActiveForumTopicsBlock() {
     $this->drupalGet('<front>');
     for ($index = 0; $index < 10; $index++) {
       if ($index < 5) {
-        $this->assertLink($topics[$index], 0, format_string('Forum topic @topic found in the "Active forum topics" block.', array('@topic' => $topics[$index])));
+        $this->assertLink($topics[$index], 0, SafeMarkup::format('Forum topic @topic found in the "Active forum topics" block.', array('@topic' => $topics[$index])));
       }
       else {
-        $this->assertNoText($topics[$index], format_string('Forum topic @topic not found in the "Active forum topics" block.', array('@topic' => $topics[$index])));
+        $this->assertNoText($topics[$index], SafeMarkup::format('Forum topic @topic not found in the "Active forum topics" block.', array('@topic' => $topics[$index])));
       }
     }
 
diff --git a/core/modules/forum/src/Tests/ForumTest.php b/core/modules/forum/src/Tests/ForumTest.php
index e75507a..3040b2b 100644
--- a/core/modules/forum/src/Tests/ForumTest.php
+++ b/core/modules/forum/src/Tests/ForumTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\forum\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\Entity\EntityFormDisplay;
 use Drupal\Core\Entity\Entity\EntityViewDisplay;
 use Drupal\Core\Entity\EntityInterface;
@@ -416,7 +417,7 @@ function createForum($type, $parent = 0) {
         'Created new @type %term.',
         array('%term' => $name, '@type' => t($type))
       ),
-      format_string('@type was created', array('@type' => ucfirst($type)))
+      SafeMarkup::format('@type was created', array('@type' => ucfirst($type)))
     );
 
     // Verify forum.
@@ -544,7 +545,7 @@ function createForumTopic($forum, $container = FALSE) {
 
     // Retrieve node object, ensure that the topic was created and in the proper forum.
     $node = $this->drupalGetNodeByTitle($title);
-    $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title)));
+    $this->assertTrue($node != NULL, SafeMarkup::format('Node @title was loaded', array('@title' => $title)));
     $this->assertEqual($node->taxonomy_forums->target_id, $tid, 'Saved forum topic was in the expected forum');
 
     // View forum topic.
diff --git a/core/modules/help/src/Tests/HelpTest.php b/core/modules/help/src/Tests/HelpTest.php
index f76e576..11c65d9 100644
--- a/core/modules/help/src/Tests/HelpTest.php
+++ b/core/modules/help/src/Tests/HelpTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\help\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -68,7 +69,7 @@ public function testHelp() {
 
     // Make sure links are properly added for modules implementing hook_help().
     foreach ($this->getModuleList() as $module => $name) {
-      $this->assertLink($name, 0, format_string('Link properly added to @name (admin/help/@module)', array('@module' => $module, '@name' => $name)));
+      $this->assertLink($name, 0, SafeMarkup::format('Link properly added to @name (admin/help/@module)', array('@module' => $module, '@name' => $name)));
     }
   }
 
@@ -93,8 +94,8 @@ protected function verifyHelp($response = 200) {
       $this->drupalGet('admin/help/' . $module);
       $this->assertResponse($response);
       if ($response == 200) {
-        $this->assertTitle($name . ' | Drupal', format_string('%module title was displayed', array('%module' => $module)));
-        $this->assertRaw('<h1 class="page-title">' . t($name) . '</h1>', format_string('%module heading was displayed', array('%module' => $module)));
+        $this->assertTitle($name . ' | Drupal', SafeMarkup::format('%module title was displayed', array('%module' => $module)));
+        $this->assertRaw('<h1 class="page-title">' . t($name) . '</h1>', SafeMarkup::format('%module heading was displayed', array('%module' => $module)));
       }
     }
   }
diff --git a/core/modules/image/src/Form/ImageEffectFormBase.php b/core/modules/image/src/Form/ImageEffectFormBase.php
index 04516bf..4507374 100644
--- a/core/modules/image/src/Form/ImageEffectFormBase.php
+++ b/core/modules/image/src/Form/ImageEffectFormBase.php
@@ -61,7 +61,7 @@ public function buildForm(array $form, FormStateInterface $form_state, ImageStyl
       $this->imageEffect = $this->prepareImageEffect($image_effect);
     }
     catch (PluginNotFoundException $e) {
-      throw new NotFoundHttpException(String::format("Invalid effect id: '@id'.", array('@id' => $image_effect)));
+      throw new NotFoundHttpException(SafeMarkup::format("Invalid effect id: '@id'.", array('@id' => $image_effect)));
     }
     $request = $this->getRequest();
 
diff --git a/core/modules/image/src/Tests/ImageAdminStylesTest.php b/core/modules/image/src/Tests/ImageAdminStylesTest.php
index 3486e49..294ff6c 100644
--- a/core/modules/image/src/Tests/ImageAdminStylesTest.php
+++ b/core/modules/image/src/Tests/ImageAdminStylesTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\image\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\image\ImageStyleInterface;
 use Drupal\node\Entity\Node;
@@ -56,7 +57,7 @@ function testNumericStyleName() {
     $this->drupalPostForm('admin/config/media/image-styles/add', $edit, t('Create new style'));
     $this->assertRaw(t('Style %name was created.', array('%name' => $style_label)));
     $options = image_style_options();
-    $this->assertTrue(array_key_exists($style_name, $options), format_string('Array key %key exists.', array('%key' => $style_name)));
+    $this->assertTrue(array_key_exists($style_name, $options), SafeMarkup::format('Array key %key exists.', array('%key' => $style_name)));
   }
 
   /**
@@ -148,13 +149,13 @@ function testStyle() {
       $uuids[$effect->getPluginId()] = $uuid;
       $effect_configuration = $effect->getConfiguration();
       foreach ($effect_edits[$effect->getPluginId()] as $field => $value) {
-        $this->assertEqual($value, $effect_configuration['data'][$field], String::format('The %field field in the %effect effect has the correct value of %value.', array('%field' => $field, '%effect' => $effect->getPluginId(), '%value' => $value)));
+        $this->assertEqual($value, $effect_configuration['data'][$field], SafeMarkup::format('The %field field in the %effect effect has the correct value of %value.', array('%field' => $field, '%effect' => $effect->getPluginId(), '%value' => $value)));
       }
     }
 
     // Assert that every effect was saved.
     foreach (array_keys($effect_edits) as $effect_name) {
-      $this->assertTrue(isset($uuids[$effect_name]), format_string(
+      $this->assertTrue(isset($uuids[$effect_name]), SafeMarkup::format(
         'A %effect_name effect was saved with ID %uuid',
         array(
           '%effect_name' => $effect_name,
@@ -193,7 +194,7 @@ function testStyle() {
 
     // Create an image to make sure it gets flushed after saving.
     $image_path = $this->createSampleImage($style);
-    $this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
+    $this->assertEqual($this->getImageCount($style), 1, SafeMarkup::format('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
 
     $this->drupalPostForm($style_path, $edit, t('Update style'));
 
@@ -203,12 +204,12 @@ function testStyle() {
     // Check that the URL was updated.
     $this->drupalGet($style_path);
     $this->assertTitle(t('Edit style @name | Drupal', array('@name' => $style_label)));
-    $this->assertResponse(200, format_string('Image style %original renamed to %new', array('%original' => $style->id(), '%new' => $style_name)));
+    $this->assertResponse(200, SafeMarkup::format('Image style %original renamed to %new', array('%original' => $style->id(), '%new' => $style_name)));
 
     // Check that the image was flushed after updating the style.
     // This is especially important when renaming the style. Make sure that
     // the old image directory has been deleted.
-    $this->assertEqual($this->getImageCount($style), 0, format_string('Image style %style was flushed after renaming the style and updating the order of effects.', array('%style' => $style->label())));
+    $this->assertEqual($this->getImageCount($style), 0, SafeMarkup::format('Image style %style was flushed after renaming the style and updating the order of effects.', array('%style' => $style->label())));
 
     // Load the style by the new name with the new weights.
     $style = entity_load('image_style', $style_name);
@@ -229,7 +230,7 @@ function testStyle() {
 
     // Create an image to make sure it gets flushed after deleting an effect.
     $image_path = $this->createSampleImage($style);
-    $this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
+    $this->assertEqual($this->getImageCount($style), 1, SafeMarkup::format('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
 
     // Delete the 'image_crop' effect from the style.
     $this->drupalPostForm($style_path . '/effects/' . $uuids['image_crop'] . '/delete', array(), t('Delete'));
@@ -242,7 +243,7 @@ function testStyle() {
     // Refresh the image style information and verify that the effect was
     // actually deleted.
     $style = entity_load_unchanged('image_style', $style->id());
-    $this->assertFalse($style->getEffects()->has($uuids['image_crop']), format_string(
+    $this->assertFalse($style->getEffects()->has($uuids['image_crop']), SafeMarkup::format(
       'Effect with ID %uuid no longer found on image style %style',
       array(
         '%uuid' => $uuids['image_crop'],
@@ -267,9 +268,9 @@ function testStyle() {
 
     // Confirm the style directory has been removed.
     $directory = file_default_scheme() . '://styles/' . $style_name;
-    $this->assertFalse(is_dir($directory), format_string('Image style %style directory removed on style deletion.', array('%style' => $style->label())));
+    $this->assertFalse(is_dir($directory), SafeMarkup::format('Image style %style directory removed on style deletion.', array('%style' => $style->label())));
 
-    $this->assertFalse(entity_load('image_style', $style_name), format_string('Image style %style successfully deleted.', array('%style' => $style->label())));
+    $this->assertFalse(entity_load('image_style', $style_name), SafeMarkup::format('Image style %style successfully deleted.', array('%style' => $style->label())));
 
   }
 
@@ -305,7 +306,7 @@ function testStyleReplacement() {
 
     // Test that image is displayed using newly created style.
     $this->drupalGet('node/' . $nid);
-    $this->assertRaw($style->buildUrl($original_uri), format_string('Image displayed using style @style.', array('@style' => $style_name)));
+    $this->assertRaw($style->buildUrl($original_uri), SafeMarkup::format('Image displayed using style @style.', array('@style' => $style_name)));
 
     // Rename the style and make sure the image field is updated.
     $new_style_name = strtolower($this->randomMachineName(10));
@@ -315,7 +316,7 @@ function testStyleReplacement() {
       'label' => $new_style_label,
     );
     $this->drupalPostForm($style_path . $style_name, $edit, t('Update style'));
-    $this->assertText(t('Changes to the style have been saved.'), format_string('Style %name was renamed to %new_name.', array('%name' => $style_name, '%new_name' => $new_style_name)));
+    $this->assertText(t('Changes to the style have been saved.'), SafeMarkup::format('Style %name was renamed to %new_name.', array('%name' => $style_name, '%new_name' => $new_style_name)));
     $this->drupalGet('node/' . $nid);
 
     // Reload the image style using the new name.
@@ -439,7 +440,7 @@ function testConfigImport() {
 
     // Test that image is displayed using newly created style.
     $this->drupalGet('node/' . $nid);
-    $this->assertRaw($style->buildUrl($original_uri), format_string('Image displayed using style @style.', array('@style' => $style_name)));
+    $this->assertRaw($style->buildUrl($original_uri), SafeMarkup::format('Image displayed using style @style.', array('@style' => $style_name)));
 
     // Copy config to staging, and delete the image style.
     $staging = $this->container->get('config.storage.staging');
diff --git a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
index 6efc84d..004ca84 100644
--- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\image\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\file\Entity\File;
 
@@ -112,7 +113,7 @@ public function testDefaultImages() {
     $this->assertFieldByXpath(
       '//input[@name="field_storage[settings][default_image][uuid][fids]"]',
       $default_images['field']->id(),
-      format_string(
+      SafeMarkup::format(
         'Article image field default equals expected file ID of @fid.',
         array('@fid' => $default_images['field']->id())
       )
@@ -122,7 +123,7 @@ public function testDefaultImages() {
     $this->assertFieldByXpath(
       '//input[@name="field[settings][default_image][uuid][fids]"]',
       $default_images['field']->id(),
-      format_string(
+      SafeMarkup::format(
         'Article image field field default equals expected file ID of @fid.',
         array('@fid' => $default_images['field']->id())
       )
@@ -133,7 +134,7 @@ public function testDefaultImages() {
     $this->assertFieldByXpath(
       '//input[@name="field_storage[settings][default_image][uuid][fids]"]',
       $default_images['field']->id(),
-      format_string(
+      SafeMarkup::format(
         'Page image field default equals expected file ID of @fid.',
         array('@fid' => $default_images['field']->id())
       )
@@ -144,7 +145,7 @@ public function testDefaultImages() {
     $this->assertFieldByXpath(
       '//input[@name="field[settings][default_image][uuid][fids]"]',
       $default_images['field2']->id(),
-      format_string(
+      SafeMarkup::format(
         'Page image field field default equals expected file ID of @fid.',
         array('@fid' => $default_images['field2']->id())
       )
@@ -156,7 +157,7 @@ public function testDefaultImages() {
     $this->assertEqual(
       $article_built[$field_name][0]['#item']->target_id,
       $default_images['field']->id(),
-      format_string(
+      SafeMarkup::format(
         'A new article node without an image has the expected default image file ID of @fid.',
         array('@fid' => $default_images['field']->id())
       )
@@ -168,7 +169,7 @@ public function testDefaultImages() {
     $this->assertEqual(
       $page_built[$field_name][0]['#item']->target_id,
       $default_images['field2']->id(),
-      format_string(
+      SafeMarkup::format(
         'A new page node without an image has the expected default image file ID of @fid.',
         array('@fid' => $default_images['field2']->id())
       )
@@ -185,7 +186,7 @@ public function testDefaultImages() {
     $this->assertFieldByXpath(
       '//input[@name="field_storage[settings][default_image][uuid][fids]"]',
       $default_images['field_new']->id(),
-      format_string(
+      SafeMarkup::format(
         'Updated image field default equals expected file ID of @fid.',
         array('@fid' => $default_images['field_new']->id())
       )
@@ -198,7 +199,7 @@ public function testDefaultImages() {
     $this->assertEqual(
       $article_built[$field_name][0]['#item']->target_id,
       $default_images['field']->id(),
-      format_string(
+      SafeMarkup::format(
         'An existing article node without an image has the expected default image file ID of @fid.',
         array('@fid' => $default_images['field']->id())
       )
@@ -206,7 +207,7 @@ public function testDefaultImages() {
     $this->assertEqual(
       $page_built[$field_name][0]['#item']->target_id,
       $default_images['field2']->id(),
-      format_string(
+      SafeMarkup::format(
         'An existing page node without an image has the expected default image file ID of @fid.',
         array('@fid' => $default_images['field2']->id())
       )
@@ -222,7 +223,7 @@ public function testDefaultImages() {
     $this->assertFieldByXpath(
       '//input[@name="field[settings][default_image][uuid][fids]"]',
       $default_images['field_new']->id(),
-      format_string(
+      SafeMarkup::format(
         'Updated article image field field default equals expected file ID of @fid.',
         array('@fid' => $default_images['field_new']->id())
       )
@@ -237,7 +238,7 @@ public function testDefaultImages() {
     $this->assertEqual(
       $article_built[$field_name][0]['#item']->target_id,
       $default_images['field_new']->id(),
-      format_string(
+      SafeMarkup::format(
         'An existing article node without an image has the expected default image file ID of @fid.',
         array('@fid' => $default_images['field_new']->id())
       )
@@ -246,7 +247,7 @@ public function testDefaultImages() {
     $this->assertEqual(
       $page_built[$field_name][0]['#item']->target_id,
       $default_images['field2']->id(),
-      format_string(
+      SafeMarkup::format(
         'An existing page node without an image has the expected default image file ID of @fid.',
         array('@fid' => $default_images['field2']->id())
       )
@@ -277,7 +278,7 @@ public function testDefaultImages() {
     $this->assertEqual(
       $article_built[$field_name][0]['#item']->target_id,
       $default_images['field_new']->id(),
-      format_string(
+      SafeMarkup::format(
         'An existing article node without an image has the expected default image file ID of @fid.',
         array('@fid' => $default_images['field_new']->id())
       )
@@ -286,7 +287,7 @@ public function testDefaultImages() {
     $this->assertEqual(
       $page_built[$field_name][0]['#item']->target_id,
       $default_images['field2']->id(),
-      format_string(
+      SafeMarkup::format(
         'An existing page node without an image has the expected default image file ID of @fid.',
         array('@fid' => $default_images['field2']->id())
       )
diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
index 29fbce3..945ec93 100644
--- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\image\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\user\RoleInterface;
@@ -304,7 +305,7 @@ function testImageFieldSettings() {
     $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
     // Add the required alt text.
     $this->drupalPostForm(NULL, [$field_name . '[1][alt]' => $alt], t('Save and keep published'));
-    $this->assertText(format_string('Article @title has been updated.', array('@title' => $node->getTitle())));
+    $this->assertText(SafeMarkup::format('Article @title has been updated.', array('@title' => $node->getTitle())));
 
     // Assert ImageWidget::process() calls FieldWidget::process().
     $this->drupalGet('node/' . $node->id() . '/edit');
diff --git a/core/modules/image/src/Tests/ImageStyleFlushTest.php b/core/modules/image/src/Tests/ImageStyleFlushTest.php
index 1ebe27b..d419d89 100644
--- a/core/modules/image/src/Tests/ImageStyleFlushTest.php
+++ b/core/modules/image/src/Tests/ImageStyleFlushTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\image\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests flushing of image styles.
@@ -85,11 +86,11 @@ function testFlush() {
     $image_path = $this->createSampleImage($style, 'public');
     // Expecting to find 2 images, one is the sample.png image shown in
     // image style preview.
-    $this->assertEqual($this->getImageCount($style, 'public'), 2, format_string('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
+    $this->assertEqual($this->getImageCount($style, 'public'), 2, SafeMarkup::format('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
 
     // Create an image for the 'private' wrapper.
     $image_path = $this->createSampleImage($style, 'private');
-    $this->assertEqual($this->getImageCount($style, 'private'), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
+    $this->assertEqual($this->getImageCount($style, 'private'), 1, SafeMarkup::format('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
 
     // Remove the 'image_scale' effect and updates the style, which in turn
     // forces an image style flush.
@@ -104,9 +105,9 @@ function testFlush() {
     $this->assertResponse(200);
 
     // Post flush, expected 1 image in the 'public' wrapper (sample.png).
-    $this->assertEqual($this->getImageCount($style, 'public'), 1, format_string('Image style %style flushed correctly for %wrapper wrapper.', array('%style' => $style->label(), '%wrapper' => 'public')));
+    $this->assertEqual($this->getImageCount($style, 'public'), 1, SafeMarkup::format('Image style %style flushed correctly for %wrapper wrapper.', array('%style' => $style->label(), '%wrapper' => 'public')));
 
     // Post flush, expected no image in the 'private' wrapper.
-    $this->assertEqual($this->getImageCount($style, 'private'), 0, format_string('Image style %style flushed correctly for %wrapper wrapper.', array('%style' => $style->label(), '%wrapper' => 'private')));
+    $this->assertEqual($this->getImageCount($style, 'private'), 0, SafeMarkup::format('Image style %style flushed correctly for %wrapper wrapper.', array('%style' => $style->label(), '%wrapper' => 'private')));
   }
 }
diff --git a/core/modules/language/src/Config/LanguageConfigCollectionNameTrait.php b/core/modules/language/src/Config/LanguageConfigCollectionNameTrait.php
index 6f7b1ad..5e36f74 100644
--- a/core/modules/language/src/Config/LanguageConfigCollectionNameTrait.php
+++ b/core/modules/language/src/Config/LanguageConfigCollectionNameTrait.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\language\Config;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -45,7 +46,7 @@ protected function createConfigCollectionName($langcode) {
   protected function getLangcodeFromCollectionName($collection) {
     preg_match('/^language\.(.*)$/', $collection, $matches);
     if (!isset($matches[1])) {
-      throw new \InvalidArgumentException(String::format('!collection is not a valid language override collection', array('!collection' => $collection)));
+      throw new \InvalidArgumentException(SafeMarkup::format('!collection is not a valid language override collection', array('!collection' => $collection)));
     }
     return $matches[1];
   }
diff --git a/core/modules/language/src/Entity/ContentLanguageSettings.php b/core/modules/language/src/Entity/ContentLanguageSettings.php
index 19ca584..d8da107 100644
--- a/core/modules/language/src/Entity/ContentLanguageSettings.php
+++ b/core/modules/language/src/Entity/ContentLanguageSettings.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\language\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Config\Entity\ConfigEntityBase;
 use Drupal\Core\Entity\EntityStorageInterface;
@@ -200,7 +201,7 @@ public function calculateDependencies() {
       // If the target entity type uses entities to manage its bundles then
       // depend on the bundle entity.
       if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->target_bundle)) {
-        throw new \LogicException(String::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->target_bundle)));
+        throw new \LogicException(SafeMarkup::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->target_bundle)));
       }
       $this->addDependency('config', $bundle_entity->getConfigDependencyName());
     }
diff --git a/core/modules/language/src/Tests/LanguageConfigurationTest.php b/core/modules/language/src/Tests/LanguageConfigurationTest.php
index dc522bc..87e6a16 100644
--- a/core/modules/language/src/Tests/LanguageConfigurationTest.php
+++ b/core/modules/language/src/Tests/LanguageConfigurationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\language\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\simpletest\WebTestBase;
@@ -186,7 +187,7 @@ protected function checkConfigurableLanguageWeight($state = 'by default') {
     $replacements = array('@event' => $state);
     foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $locked_language) {
       $replacements['%language'] = $locked_language->getName();
-      $this->assertTrue($locked_language->getWeight() > $max_configurable_language_weight, format_string('System language %language has higher weight than configurable languages @event', $replacements));
+      $this->assertTrue($locked_language->getWeight() > $max_configurable_language_weight, SafeMarkup::format('System language %language has higher weight than configurable languages @event', $replacements));
     }
   }
 
diff --git a/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php b/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php
index 1a7a815..ce6b438 100644
--- a/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php
+++ b/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\language\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Drupal\Core\Language\Language;
 use Drupal\language\Entity\ConfigurableLanguage;
@@ -29,7 +30,7 @@ function testDependencyInjectedNewLanguage() {
     $expected = $this->languageManager->getDefaultLanguage();
     $result = $this->languageManager->getCurrentLanguage();
     foreach ($expected as $property => $value) {
-      $this->assertEqual($expected->$property, $result->$property, format_string('The dependency injected language object %prop property equals the new Language object %prop property.', array('%prop' => $property)));
+      $this->assertEqual($expected->$property, $result->$property, SafeMarkup::format('The dependency injected language object %prop property equals the new Language object %prop property.', array('%prop' => $property)));
     }
   }
 
diff --git a/core/modules/language/src/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/src/Tests/LanguageNegotiationInfoTest.php
index d96e310..2cc7003 100644
--- a/core/modules/language/src/Tests/LanguageNegotiationInfoTest.php
+++ b/core/modules/language/src/Tests/LanguageNegotiationInfoTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\language\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI;
 use Drupal\simpletest\WebTestBase;
@@ -117,10 +118,10 @@ function testInfoAlterations() {
     foreach ($this->languageManager()->getLanguageTypes() as $type) {
       $form_field = $type . '[enabled][test_language_negotiation_method_ts]';
       if ($type == $test_type) {
-        $this->assertFieldByName($form_field, NULL, format_string('Type-specific test language negotiation method available for %type.', array('%type' => $type)));
+        $this->assertFieldByName($form_field, NULL, SafeMarkup::format('Type-specific test language negotiation method available for %type.', array('%type' => $type)));
       }
       else {
-        $this->assertNoFieldByName($form_field, NULL, format_string('Type-specific test language negotiation method unavailable for %type.', array('%type' => $type)));
+        $this->assertNoFieldByName($form_field, NULL, SafeMarkup::format('Type-specific test language negotiation method unavailable for %type.', array('%type' => $type)));
       }
     }
 
@@ -130,7 +131,7 @@ function testInfoAlterations() {
     foreach ($this->languageManager()->getDefinedLanguageTypes() as $type) {
       $langcode = $last[$type];
       $value = $type == LanguageInterface::TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en';
-      $this->assertEqual($langcode, $value, format_string('The negotiated language for %type is %language', array('%type' => $type, '%language' => $value)));
+      $this->assertEqual($langcode, $value, SafeMarkup::format('The negotiated language for %type is %language', array('%type' => $type, '%language' => $value)));
     }
 
     // Uninstall language_test and check that everything is set back to the
@@ -140,7 +141,7 @@ function testInfoAlterations() {
 
     // Check that only the core language types are available.
     foreach ($this->languageManager()->getDefinedLanguageTypes() as $type) {
-      $this->assertTrue(strpos($type, 'test') === FALSE, format_string('The %type language is still available', array('%type' => $type)));
+      $this->assertTrue(strpos($type, 'test') === FALSE, SafeMarkup::format('The %type language is still available', array('%type' => $type)));
     }
 
     // Check that fixed language types are properly configured, even those
@@ -170,7 +171,7 @@ protected function checkFixedLanguageTypes() {
           list(, $info_id) = each($info['fixed']);
           $equal = $info_id == $id;
         }
-        $this->assertTrue($equal, format_string('language negotiation for %type is properly set up', array('%type' => $type)));
+        $this->assertTrue($equal, SafeMarkup::format('language negotiation for %type is properly set up', array('%type' => $type)));
       }
     }
   }
diff --git a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php
index f801b6a..116d55c 100644
--- a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php
+++ b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\language\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Url;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationBrowser;
@@ -467,19 +468,19 @@ function testLanguageDomain() {
     $italian_url = Url::fromRoute('system.admin', [], ['language' => $languages['it']])->toString();
     $url_scheme = \Drupal::request()->isSecure() ? 'https://' : 'http://';
     $correct_link = $url_scheme . $link;
-    $this->assertEqual($italian_url, $correct_link, format_string('The right URL (@url) in accordance with the chosen language', array('@url' => $italian_url)));
+    $this->assertEqual($italian_url, $correct_link, SafeMarkup::format('The right URL (@url) in accordance with the chosen language', array('@url' => $italian_url)));
 
     // Test HTTPS via options.
     $italian_url = Url::fromRoute('system.admin', [], ['https' => TRUE, 'language' => $languages['it']])->toString();
     $correct_link = 'https://' . $link;
-    $this->assertTrue($italian_url == $correct_link, format_string('The right HTTPS URL (via options) (@url) in accordance with the chosen language', array('@url' => $italian_url)));
+    $this->assertTrue($italian_url == $correct_link, SafeMarkup::format('The right HTTPS URL (via options) (@url) in accordance with the chosen language', array('@url' => $italian_url)));
 
     // Test HTTPS via current URL scheme.
     $request = Request::create('', 'GET', array(), array(), array(), array('HTTPS' => 'on'));
     $this->container->get('request_stack')->push($request);
     $italian_url = Url::fromRoute('system.admin', [], ['language' => $languages['it']])->toString();
     $correct_link = 'https://' . $link;
-    $this->assertTrue($italian_url == $correct_link, format_string('The right URL (via current URL scheme) (@url) in accordance with the chosen language', array('@url' => $italian_url)));
+    $this->assertTrue($italian_url == $correct_link, SafeMarkup::format('The right URL (via current URL scheme) (@url) in accordance with the chosen language', array('@url' => $italian_url)));
   }
 
   /**
diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc
index 596df97..3da948c 100644
--- a/core/modules/locale/locale.pages.inc
+++ b/core/modules/locale/locale.pages.inc
@@ -61,7 +61,7 @@ function template_preprocess_locale_translation_update_info(array &$variables) {
     if ($variables['updates']) {
       foreach ($variables['updates'] as $update) {
         $modules[] = $update['name'];
-        $releases[] = String::format('@module (@date)', array(
+        $releases[] = SafeMarkup::format('@module (@date)', array(
           '@module' => $update['name'],
           '@date' => format_date($update['timestamp'], 'html_date'),
         ));
@@ -81,7 +81,7 @@ function template_preprocess_locale_translation_update_info(array &$variables) {
     if ($variables['not_found']) {
       foreach ($variables['not_found'] as $update) {
         $version = $update['version'] ? $update['version'] : t('no version');
-        $releases[] = String::format('@module (@version). !info', array(
+        $releases[] = SafeMarkup::format('@module (@version). !info', array(
           '@module' => $update['name'],
           '@version' => $version,
           '!info' => $update['info'],
diff --git a/core/modules/locale/src/StringBase.php b/core/modules/locale/src/StringBase.php
index f6cfffd..6aa987d 100644
--- a/core/modules/locale/src/StringBase.php
+++ b/core/modules/locale/src/StringBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\locale;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -190,7 +191,7 @@ public function save() {
       $storage->save($this);
     }
     else {
-      throw new StringStorageException(String::format('The string cannot be saved because its not bound to a storage: @string', array(
+      throw new StringStorageException(SafeMarkup::format('The string cannot be saved because its not bound to a storage: @string', array(
         '@string' => $this->getString(),
       )));
     }
@@ -206,7 +207,7 @@ public function delete() {
         $storage->delete($this);
       }
       else {
-        throw new StringStorageException(String::format('The string cannot be deleted because its not bound to a storage: @string', array(
+        throw new StringStorageException(SafeMarkup::format('The string cannot be deleted because its not bound to a storage: @string', array(
           '@string' => $this->getString(),
         )));
       }
diff --git a/core/modules/locale/src/StringDatabaseStorage.php b/core/modules/locale/src/StringDatabaseStorage.php
index d09e5a6..9619075 100644
--- a/core/modules/locale/src/StringDatabaseStorage.php
+++ b/core/modules/locale/src/StringDatabaseStorage.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\locale;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Database\Connection;
 
 /**
@@ -199,7 +200,7 @@ public function delete($string) {
       }
     }
     else {
-      throw new StringStorageException(format_string('The string cannot be deleted because it lacks some key fields: @string', array(
+      throw new StringStorageException(SafeMarkup::format('The string cannot be deleted because it lacks some key fields: @string', array(
         '@string' => $string->getString(),
       )));
     }
@@ -483,7 +484,7 @@ protected function dbStringInsert($string) {
         ->execute();
     }
     else {
-      throw new StringStorageException(format_string('The string cannot be saved: @string', array(
+      throw new StringStorageException(SafeMarkup::format('The string cannot be saved: @string', array(
           '@string' => $string->getString(),
       )));
     }
@@ -516,7 +517,7 @@ protected function dbStringUpdate($string) {
         ->execute();
     }
     else {
-      throw new StringStorageException(format_string('The string cannot be updated: @string', array(
+      throw new StringStorageException(SafeMarkup::format('The string cannot be updated: @string', array(
           '@string' => $string->getString(),
       )));
     }
diff --git a/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
index 35c9a66..69823f2 100644
--- a/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
+++ b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\locale\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 use Drupal\Core\Language\LanguageInterface;
 
@@ -324,7 +325,7 @@ public function testConfigPoFile() {
         'translation' => 'all',
       );
       $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
-      $this->assertText($config_string[1], format_string('Translation of @string found.', array('@string' => $config_string[0])));
+      $this->assertText($config_string[1], SafeMarkup::format('Translation of @string found.', array('@string' => $config_string[0])));
     }
 
     // Test that translations got recorded in the config system.
diff --git a/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php b/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php
index e8b9412..fcabdc9 100644
--- a/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php
+++ b/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\locale\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\simpletest\WebTestBase;
 use Drupal\Component\Utility\String;
@@ -85,10 +86,10 @@ public function testFileParsing() {
       $args = array('%source' => $str, '%context' => $context);
 
       // Make sure that the string was found in the file.
-      $this->assertTrue(isset($source_strings[$str]), String::format('Found source string: %source', $args));
+      $this->assertTrue(isset($source_strings[$str]), SafeMarkup::format('Found source string: %source', $args));
 
       // Make sure that the proper context was matched.
-      $message = $context ? String::format('Context for %source is %context', $args) : String::format('Context for %source is blank', $args);
+      $message = $context ? SafeMarkup::format('Context for %source is %context', $args) : SafeMarkup::format('Context for %source is blank', $args);
       $this->assertTrue(isset($source_strings[$str]) && $source_strings[$str] === $context, $message);
     }
 
diff --git a/core/modules/locale/src/Tests/LocaleStringTest.php b/core/modules/locale/src/Tests/LocaleStringTest.php
index 430b024..17ce85a 100644
--- a/core/modules/locale/src/Tests/LocaleStringTest.php
+++ b/core/modules/locale/src/Tests/LocaleStringTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\locale\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\simpletest\WebTestBase;
 
@@ -51,7 +52,7 @@ public function testStringCRUDAPI() {
     // Create source string.
     $source = $this->buildSourceString();
     $source->save();
-    $this->assertTrue($source->lid, format_string('Successfully created string %string', array('%string' => $source->source)));
+    $this->assertTrue($source->lid, SafeMarkup::format('Successfully created string %string', array('%string' => $source->source)));
 
     // Load strings by lid and source.
     $string1 = $this->storage->findString(array('lid' => $source->lid));
diff --git a/core/modules/locale/src/Tests/LocaleTranslationUiTest.php b/core/modules/locale/src/Tests/LocaleTranslationUiTest.php
index 83a967d..ba498e3 100644
--- a/core/modules/locale/src/Tests/LocaleTranslationUiTest.php
+++ b/core/modules/locale/src/Tests/LocaleTranslationUiTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\locale\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\simpletest\WebTestBase;
 use Drupal\Core\Language\LanguageInterface;
@@ -251,13 +252,13 @@ public function testJavaScriptTranslation() {
 
     $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array();
     $js_file = 'public://' . $config->get('javascript.directory') . '/' . $langcode . '_' . $locale_javascripts[$langcode] . '.js';
-    $this->assertTrue($result = file_exists($js_file), String::format('JavaScript file created: %file', array('%file' => $result ? $js_file : 'not found')));
+    $this->assertTrue($result = file_exists($js_file), SafeMarkup::format('JavaScript file created: %file', array('%file' => $result ? $js_file : 'not found')));
 
     // Test JavaScript translation rebuilding.
     file_unmanaged_delete($js_file);
-    $this->assertTrue($result = !file_exists($js_file), String::format('JavaScript file deleted: %file', array('%file' => $result ? $js_file : 'found')));
+    $this->assertTrue($result = !file_exists($js_file), SafeMarkup::format('JavaScript file deleted: %file', array('%file' => $result ? $js_file : 'found')));
     _locale_rebuild_js($langcode);
-    $this->assertTrue($result = file_exists($js_file), String::format('JavaScript file rebuilt: %file', array('%file' => $result ? $js_file : 'not found')));
+    $this->assertTrue($result = file_exists($js_file), SafeMarkup::format('JavaScript file rebuilt: %file', array('%file' => $result ? $js_file : 'not found')));
   }
 
   /**
diff --git a/core/modules/locale/src/Tests/LocaleUpdateBase.php b/core/modules/locale/src/Tests/LocaleUpdateBase.php
index 8397221..fd9813a 100644
--- a/core/modules/locale/src/Tests/LocaleUpdateBase.php
+++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\locale\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\StreamWrapper\PublicStream;
 use Drupal\Core\Url;
 use Drupal\simpletest\WebTestBase;
@@ -98,7 +99,7 @@ protected function addLanguage($langcode) {
     $edit = array('predefined_langcode' => $langcode);
     $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
     $this->container->get('language_manager')->reset();
-    $this->assertTrue(\Drupal::languageManager()->getLanguage($langcode), String::format('Language %langcode added.', array('%langcode' => $langcode)));
+    $this->assertTrue(\Drupal::languageManager()->getLanguage($langcode), SafeMarkup::format('Language %langcode added.', array('%langcode' => $langcode)));
   }
 
   /**
@@ -308,6 +309,6 @@ protected function setCurrentTranslations() {
   protected function assertTranslation($source, $translation, $langcode, $message = '') {
     $db_translation = db_query('SELECT translation FROM {locales_target} lt INNER JOIN {locales_source} ls ON ls.lid = lt.lid WHERE ls.source = :source AND lt.language = :langcode', array(':source' => $source, ':langcode' => $langcode))->fetchField();
     $db_translation = $db_translation == FALSE ? '' : $db_translation;
-    $this->assertEqual($translation, $db_translation, $message ? $message : format_string('Correct translation of %source (%language)', array('%source' => $source, '%language' => $langcode)));
+    $this->assertEqual($translation, $db_translation, $message ? $message : SafeMarkup::format('Correct translation of %source (%language)', array('%source' => $source, '%language' => $langcode)));
   }
 }
diff --git a/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php b/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php
index d26a070..3411be0 100644
--- a/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php
+++ b/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\locale\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -87,7 +88,7 @@ public function testInterface() {
     $this->assertRaw(t('Missing translations for: @languages. See the <a href="@updates">Available translation updates</a> page for more information.', array('@languages' => t('German'), '@updates' => \Drupal::url('locale.translate_status'))), 'Missing translations message');
     $this->drupalGet('admin/reports/translations');
     $this->assertText(t('Missing translations for one project'), 'No translations found');
-    $this->assertText(String::format('@module (@version). !info', array('@module' => 'Locale test translate', '@version' => '1.3-dev', '!info' => t('No translation files are provided for development releases.'))), 'Release details');
+    $this->assertText(SafeMarkup::format('@module (@version). !info', array('@module' => 'Locale test translate', '@version' => '1.3-dev', '!info' => t('No translation files are provided for development releases.'))), 'Release details');
     $this->assertText(t('No translation files are provided for development releases.'), 'Release info');
 
     // Override Drupal core translation status as 'no translations found'.
@@ -112,7 +113,7 @@ public function testInterface() {
     // Check if translations are available for Drupal core.
     $this->drupalGet('admin/reports/translations');
     $this->assertText(t('Updates for: !project', array('!project' => t('Drupal core'))), 'Translations found');
-    $this->assertText(String::format('@module (@date)', array('@module' => t('Drupal core'), '@date' => format_date(REQUEST_TIME, 'html_date'))), 'Core translation update');
+    $this->assertText(SafeMarkup::format('@module (@date)', array('@module' => t('Drupal core'), '@date' => format_date(REQUEST_TIME, 'html_date'))), 'Core translation update');
     $update_button = $this->xpath('//input[@type="submit"][@value="' . t('Update translations') . '"]');
     $this->assertTrue($update_button, 'Update translations button');
   }
diff --git a/core/modules/locale/src/Tests/LocaleUpdateTest.php b/core/modules/locale/src/Tests/LocaleUpdateTest.php
index 0a13796..44bf5dc 100644
--- a/core/modules/locale/src/Tests/LocaleUpdateTest.php
+++ b/core/modules/locale/src/Tests/LocaleUpdateTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\locale\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Language\LanguageInterface;
 
 /**
@@ -47,7 +48,7 @@ public function testUpdateProjects() {
     $projects = locale_translation_project_list();
     $this->assertFalse(isset($projects['locale_test_translate']), 'Hidden module not found');
     $this->assertEqual($projects['locale_test']['info']['interface translation server pattern'], 'core/modules/locale/test/test.%language.po', 'Interface translation parameter found in project info.');
-    $this->assertEqual($projects['locale_test']['name'], 'locale_test', format_string('%key found in project info.', array('%key' => 'interface translation project')));
+    $this->assertEqual($projects['locale_test']['name'], 'locale_test', SafeMarkup::format('%key found in project info.', array('%key' => 'interface translation project')));
   }
 
   /**
diff --git a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php
index 8e3433b..5361875 100644
--- a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php
+++ b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php
@@ -8,6 +8,7 @@
 namespace Drupal\menu_link_content\Plugin\Menu;
 
 use Drupal\Component\Plugin\Exception\PluginException;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Language\LanguageManagerInterface;
@@ -138,7 +139,7 @@ protected function getEntity() {
         $entity = reset($loaded_entities);
       }
       if (!$entity) {
-        throw new PluginException(String::format('Entity not found through the menu link plugin definition and could not fallback on UUID @uuid', array('@uuid' => $uuid)));
+        throw new PluginException(SafeMarkup::format('Entity not found through the menu link plugin definition and could not fallback on UUID @uuid', array('@uuid' => $uuid)));
       }
       // Clone the entity object to avoid tampering with the static cache.
       $this->entity = clone $entity;
diff --git a/core/modules/menu_link_content/src/Tests/LinksTest.php b/core/modules/menu_link_content/src/Tests/LinksTest.php
index 92f18b6..9661b9c 100644
--- a/core/modules/menu_link_content/src/Tests/LinksTest.php
+++ b/core/modules/menu_link_content/src/Tests/LinksTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\menu_link_content\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\locale\TranslationString;
 use Drupal\simpletest\WebTestBase;
@@ -117,7 +118,7 @@ function assertMenuLinkParents($links, $expected_hierarchy) {
       $menu_link_plugin = $this->menuLinkManager->createInstance($links[$id]);
       $expected_parent = isset($links[$parent]) ? $links[$parent] : '';
 
-      $this->assertEqual($menu_link_plugin->getParent(), $expected_parent, String::format('Menu link %id has parent of %parent, expected %expected_parent.', array('%id' => $id, '%parent' => $menu_link_plugin->getParent(), '%expected_parent' => $expected_parent)));
+      $this->assertEqual($menu_link_plugin->getParent(), $expected_parent, SafeMarkup::format('Menu link %id has parent of %parent, expected %expected_parent.', array('%id' => $id, '%parent' => $menu_link_plugin->getParent(), '%expected_parent' => $expected_parent)));
     }
   }
 
diff --git a/core/modules/menu_ui/src/Tests/MenuTest.php b/core/modules/menu_ui/src/Tests/MenuTest.php
index 5cb6563..0c29071 100644
--- a/core/modules/menu_ui/src/Tests/MenuTest.php
+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -9,6 +9,7 @@
 
 use Drupal\block\Entity\Block;
 use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Menu\MenuLinkInterface;
@@ -569,7 +570,7 @@ public function testBlockContextualLinks() {
 
     $id = 'block:block=' . $block->id() . ':|menu:menu=' . $custom_menu->id() . ':';
     // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
-    $this->assertRaw('<div data-contextual-id="'. $id . '"></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
+    $this->assertRaw('<div data-contextual-id="'. $id . '"></div>', SafeMarkup::format('Contextual link placeholder with id @id exists.', array('@id' => $id)));
 
     // Get server-rendered contextual links.
     // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
@@ -583,7 +584,7 @@ public function testBlockContextualLinks() {
     $this->drupalPostForm('admin/structure/block/manage/' . $block->id(), ['settings[cache][max_age]' => Cache::PERMANENT], t('Save block'));
     $this->drupalGet('test-page');
     $id = 'block:block=' . $block->id() . ':|menu:menu=' . $custom_menu->id() . ':';
-    $this->assertRaw('<div data-contextual-id="'. $id . '"></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
+    $this->assertRaw('<div data-contextual-id="'. $id . '"></div>', SafeMarkup::format('Contextual link placeholder with id @id exists.', array('@id' => $id)));
   }
 
   /**
diff --git a/core/modules/migrate/src/Entity/Migration.php b/core/modules/migrate/src/Entity/Migration.php
index 9e8fe46..65b3aff 100644
--- a/core/modules/migrate/src/Entity/Migration.php
+++ b/core/modules/migrate/src/Entity/Migration.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\migrate\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Config\Entity\ConfigEntityBase;
 use Drupal\migrate\Exception\RequirementsException;
@@ -352,7 +353,7 @@ public function checkRequirements() {
       }
     }
     if ($missing_migrations) {
-      throw new RequirementsException(String::format('Missing migrations @requirements.', ['@requirements' => implode(', ', $missing_migrations)]), ['requirements' => $missing_migrations]);
+      throw new RequirementsException(SafeMarkup::format('Missing migrations @requirements.', ['@requirements' => implode(', ', $missing_migrations)]), ['requirements' => $missing_migrations]);
     }
   }
 
diff --git a/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php b/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php
index 36c731f..7b141a9 100644
--- a/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php
+++ b/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Tests\migrate\Unit;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Database\Connection;
 use Drupal\migrate\Entity\MigrationInterface;
@@ -61,7 +62,7 @@ protected function getFieldSchema(array $id_definition) {
           'not null' => FALSE,
         );
       default:
-        throw new MigrateException(String::format('@type not supported', array('@type' => $id_definition['type'])));
+        throw new MigrateException(SafeMarkup::format('@type not supported', array('@type' => $id_definition['type'])));
     }
   }
 }
diff --git a/core/modules/migrate_drupal/src/MigrationStorage.php b/core/modules/migrate_drupal/src/MigrationStorage.php
index 7382605..2ce0d75 100644
--- a/core/modules/migrate_drupal/src/MigrationStorage.php
+++ b/core/modules/migrate_drupal/src/MigrationStorage.php
@@ -125,7 +125,7 @@ protected function getDynamicIds(array &$dynamic_ids, array $entities) {
    */
   public function save(EntityInterface $entity) {
     if (strpos($entity->id(), ':') !== FALSE) {
-      throw new EntityStorageException(String::format("Dynamic migration %id can't be saved", array('$%id' => $entity->id())));
+      throw new EntityStorageException(SafeMarkup::format("Dynamic migration %id can't be saved", array('$%id' => $entity->id())));
     }
     return parent::save($entity);
   }
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php b/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php
index f04672d..51e36b2 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\migrate_drupal\Plugin\migrate\load;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Plugin\PluginBase;
@@ -44,7 +45,7 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi
       throw new MigrateException('Migrations with a load plugin using LoadEntity should have an entity as source.');
     }
     if ($source_plugin->bundleMigrationRequired() && empty($configuration['bundle_migration'])) {
-      throw new MigrateException(String::format('Source plugin @plugin requires the bundle_migration key to be set.', array('@plugin' => $source_plugin->getPluginId())));
+      throw new MigrateException(SafeMarkup::format('Source plugin @plugin requires the bundle_migration key to be set.', array('@plugin' => $source_plugin->getPluginId())));
     }
   }
 
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
index 24b5067..2a83ac8 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\migrate_drupal\Plugin\migrate\source;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Drupal\migrate\Entity\MigrationInterface;
@@ -81,11 +82,11 @@ public function checkRequirements() {
       if (isset($this->pluginDefinition['source_provider'])) {
         if ($this->moduleExists($this->pluginDefinition['source_provider'])) {
           if (isset($this->pluginDefinition['minimum_schema_version']) && !$this->getModuleSchemaVersion($this->pluginDefinition['source_provider']) < $this->pluginDefinition['minimum_schema_version']) {
-            throw new RequirementsException(String::format('Required minimum schema version @minimum_schema_version', ['@minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]), ['minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]);
+            throw new RequirementsException(SafeMarkup::format('Required minimum schema version @minimum_schema_version', ['@minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]), ['minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]);
           }
         }
         else {
-          throw new RequirementsException(String::format('Missing source provider @provider', ['@provider' => $this->pluginDefinition['source_provider']]), ['source_provider' => $this->pluginDefinition['source_provider']]);
+          throw new RequirementsException(SafeMarkup::format('Missing source provider @provider', ['@provider' => $this->pluginDefinition['source_provider']]), ['source_provider' => $this->pluginDefinition['source_provider']]);
         }
       }
     }
diff --git a/core/modules/migrate_drupal/src/Tests/dependencies/MigrateDependenciesTest.php b/core/modules/migrate_drupal/src/Tests/dependencies/MigrateDependenciesTest.php
index 8907986..cc36036 100644
--- a/core/modules/migrate_drupal/src/Tests/dependencies/MigrateDependenciesTest.php
+++ b/core/modules/migrate_drupal/src/Tests/dependencies/MigrateDependenciesTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\migrate_drupal\Tests\dependencies;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\migrate\MigrateExecutable;
 use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
@@ -62,7 +63,7 @@ public function testAggregatorMigrateDependencies() {
     $executable = new MigrateExecutable($migration, $this);
     $this->startCollectingMessages();
     $executable->import();
-    $this->assertIdentical($this->migrateMessages['error'], array(String::format('Migration @id did not meet the requirements. Missing migrations d6_aggregator_feed. requirements: d6_aggregator_feed.', array('@id' => $migration->id()))));
+    $this->assertIdentical($this->migrateMessages['error'], array(SafeMarkup::format('Migration @id did not meet the requirements. Missing migrations d6_aggregator_feed. requirements: d6_aggregator_feed.', array('@id' => $migration->id()))));
     $this->collectMessages = FALSE;
   }
 
diff --git a/core/modules/node/src/Tests/NodeAccessRecordsTest.php b/core/modules/node/src/Tests/NodeAccessRecordsTest.php
index 4b019c8..f4b7a34 100644
--- a/core/modules/node/src/Tests/NodeAccessRecordsTest.php
+++ b/core/modules/node/src/Tests/NodeAccessRecordsTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\node\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\node\Entity\Node;
 
 /**
@@ -76,7 +77,7 @@ function testNodeAccessRecords() {
       $grants = node_test_node_grants($web_user, $op);
       $altered_grants = $grants;
       \Drupal::moduleHandler()->alter('node_grants', $altered_grants, $web_user, $op);
-      $this->assertNotEqual($grants, $altered_grants, format_string('Altered the %op grant for a user.', array('%op' => $op)));
+      $this->assertNotEqual($grants, $altered_grants, SafeMarkup::format('Altered the %op grant for a user.', array('%op' => $op)));
     }
 
     // Check that core does not grant access to an unpublished node when an
diff --git a/core/modules/node/src/Tests/NodeFieldAccessTest.php b/core/modules/node/src/Tests/NodeFieldAccessTest.php
index bc1ef76..430bbfd 100644
--- a/core/modules/node/src/Tests/NodeFieldAccessTest.php
+++ b/core/modules/node/src/Tests/NodeFieldAccessTest.php
@@ -6,6 +6,7 @@
 
 namespace Drupal\node\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\node\Entity\Node;
 use Drupal\node\Entity\NodeType;
@@ -105,35 +106,35 @@ function testAccessToAdministrativeFields() {
       // Checks on view operations.
       foreach ($test_users as $account) {
         $may_view = $node1->{$field}->access('view', $account);
-        $this->assertTrue($may_view, String::format('Any user may view the field @name.', array('@name' => $field)));
+        $this->assertTrue($may_view, SafeMarkup::format('Any user may view the field @name.', array('@name' => $field)));
       }
 
       // Checks on edit operations.
       $may_update = $node1->{$field}->access('edit', $page_creator_user);
-      $this->assertFalse($may_update, String::format('Users with permission "edit own page content" is not allowed to the field @name.', array('@name' => $field)));
+      $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit own page content" is not allowed to the field @name.', array('@name' => $field)));
       $may_update = $node2->{$field}->access('edit', $page_creator_user);
-      $this->assertFalse($may_update, String::format('Users with permission "edit own page content" is not allowed to the field @name.', array('@name' => $field)));
+      $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit own page content" is not allowed to the field @name.', array('@name' => $field)));
       $may_update = $node2->{$field}->access('edit', $page_manager_user);
-      $this->assertFalse($may_update, String::format('Users with permission "edit any page content" is not allowed to the field @name.', array('@name' => $field)));
+      $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit any page content" is not allowed to the field @name.', array('@name' => $field)));
       $may_update = $node1->{$field}->access('edit', $page_manager_user);
-      $this->assertFalse($may_update, String::format('Users with permission "edit any page content" is not allowed to the field @name.', array('@name' => $field)));
+      $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit any page content" is not allowed to the field @name.', array('@name' => $field)));
       $may_update = $node2->{$field}->access('edit', $page_unrelated_user);
-      $this->assertFalse($may_update, String::format('Users not having permission "edit any page content" is not allowed to the field @name.', array('@name' => $field)));
+      $this->assertFalse($may_update, SafeMarkup::format('Users not having permission "edit any page content" is not allowed to the field @name.', array('@name' => $field)));
       $may_update = $node1->{$field}->access('edit', $content_admin_user) && $node3->status->access('edit', $content_admin_user);
-      $this->assertTrue($may_update, String::format('Users with permission "administer nodes" may edit @name fields on all nodes.', array('@name' => $field)));
+      $this->assertTrue($may_update, SafeMarkup::format('Users with permission "administer nodes" may edit @name fields on all nodes.', array('@name' => $field)));
     }
 
     foreach ($this->readOnlyFields as $field) {
       // Check view operation.
       foreach ($test_users as $account) {
         $may_view = $node1->{$field}->access('view', $account);
-        $this->assertTrue($may_view, String::format('Any user may view the field @name.', array('@name' => $field)));
+        $this->assertTrue($may_view, SafeMarkup::format('Any user may view the field @name.', array('@name' => $field)));
       }
 
       // Check edit operation.
       foreach ($test_users as $account) {
         $may_view = $node1->{$field}->access('edit', $account);
-        $this->assertFalse($may_view, String::format('No user is not allowed to edit the field @name.', array('@name' => $field)));
+        $this->assertFalse($may_view, SafeMarkup::format('No user is not allowed to edit the field @name.', array('@name' => $field)));
       }
     }
 
diff --git a/core/modules/node/src/Tests/NodeLoadMultipleTest.php b/core/modules/node/src/Tests/NodeLoadMultipleTest.php
index afb1d30..a9829ec 100644
--- a/core/modules/node/src/Tests/NodeLoadMultipleTest.php
+++ b/core/modules/node/src/Tests/NodeLoadMultipleTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\node\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\node\Entity\Node;
 
 /**
@@ -50,12 +51,12 @@ function testNodeMultipleLoad() {
     $this->assertEqual($node3->label(), $nodes[$node3->id()]->label(), 'Node was loaded.');
     $this->assertEqual($node4->label(), $nodes[$node4->id()]->label(), 'Node was loaded.');
     $count = count($nodes);
-    $this->assertTrue($count == 2, format_string('@count nodes loaded.', array('@count' => $count)));
+    $this->assertTrue($count == 2, SafeMarkup::format('@count nodes loaded.', array('@count' => $count)));
 
     // Load nodes by nid. Nodes 1, 2 and 4 will be loaded.
     $nodes = Node::loadMultiple(array(1, 2, 4));
     $count = count($nodes);
-    $this->assertTrue(count($nodes) == 3, format_string('@count nodes loaded', array('@count' => $count)));
+    $this->assertTrue(count($nodes) == 3, SafeMarkup::format('@count nodes loaded', array('@count' => $count)));
     $this->assertTrue(isset($nodes[$node1->id()]), 'Node is correctly keyed in the array');
     $this->assertTrue(isset($nodes[$node2->id()]), 'Node is correctly keyed in the array');
     $this->assertTrue(isset($nodes[$node4->id()]), 'Node is correctly keyed in the array');
diff --git a/core/modules/node/src/Tests/NodeTestBase.php b/core/modules/node/src/Tests/NodeTestBase.php
index 7d38bb5..35cfa6a 100644
--- a/core/modules/node/src/Tests/NodeTestBase.php
+++ b/core/modules/node/src/Tests/NodeTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\node\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\simpletest\WebTestBase;
 
@@ -105,7 +106,7 @@ function assertNodeCreateAccess($bundle, $result, AccountInterface $account, $la
    * @return string
    */
   function nodeAccessAssertMessage($operation, $result, $langcode = NULL) {
-    return format_string(
+    return SafeMarkup::format(
       'Node access returns @result with operation %op, language code %langcode.',
       array(
         '@result' => $result ? 'true' : 'false',
diff --git a/core/modules/node/src/Tests/NodeTokenReplaceTest.php b/core/modules/node/src/Tests/NodeTokenReplaceTest.php
index 7431f06..ee88bcc 100644
--- a/core/modules/node/src/Tests/NodeTokenReplaceTest.php
+++ b/core/modules/node/src/Tests/NodeTokenReplaceTest.php
@@ -81,7 +81,7 @@ function testNodeTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->getId()));
-      $this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Sanitized node token %token replaced.', array('%token' => $input)));
     }
 
     // Generate and test unsanitized tokens.
@@ -93,7 +93,7 @@ function testNodeTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->getId(), 'sanitize' => FALSE));
-      $this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Unsanitized node token %token replaced.', array('%token' => $input)));
     }
 
     // Repeat for a node without a summary.
@@ -114,7 +114,7 @@ function testNodeTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $this->tokenService->replace($input, array('node' => $node), array('language' => $this->interfaceLanguage));
-      $this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced for node without a summary.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Sanitized node token %token replaced for node without a summary.', array('%token' => $input)));
     }
 
     // Generate and test unsanitized tokens.
@@ -122,7 +122,7 @@ function testNodeTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $this->tokenService->replace($input, array('node' => $node), array('language' => $this->interfaceLanguage, 'sanitize' => FALSE));
-      $this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced for node without a summary.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Unsanitized node token %token replaced for node without a summary.', array('%token' => $input)));
     }
   }
 
diff --git a/core/modules/node/src/Tests/NodeTranslationUITest.php b/core/modules/node/src/Tests/NodeTranslationUITest.php
index 80a9d1e..6b73bcf 100644
--- a/core/modules/node/src/Tests/NodeTranslationUITest.php
+++ b/core/modules/node/src/Tests/NodeTranslationUITest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\node\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\content_translation\Tests\ContentTranslationUITest;
 use Drupal\Core\Language\LanguageInterface;
@@ -316,7 +317,7 @@ protected function doTestTranslations($path, array $values) {
     $languages = $this->container->get('language_manager')->getLanguages();
     foreach ($this->langcodes as $langcode) {
       $this->drupalGet($path, array('language' => $languages[$langcode]));
-      $this->assertText($values[$langcode]['title'][0]['value'], format_string('The %langcode node translation is correctly displayed.', array('%langcode' => $langcode)));
+      $this->assertText($values[$langcode]['title'][0]['value'], SafeMarkup::format('The %langcode node translation is correctly displayed.', array('%langcode' => $langcode)));
     }
   }
 
@@ -340,7 +341,7 @@ protected function doTestAlternateHreflangLinks(Url $url) {
         // Retrieve desired link elements from the HTML head.
         $links = $this->xpath('head/link[@rel = "alternate" and @href = :href and @hreflang = :hreflang]',
           array(':href' => $language_url->toString(), ':hreflang' => $alternate_langcode));
-        $this->assert(isset($links[0]), format_string('The %langcode node translation has the correct alternate hreflang link for %alternate_langcode: %link.', array('%langcode' => $langcode, '%alternate_langcode' => $alternate_langcode, '%link' => $url->toString())));
+        $this->assert(isset($links[0]), SafeMarkup::format('The %langcode node translation has the correct alternate hreflang link for %alternate_langcode: %link.', array('%langcode' => $langcode, '%alternate_langcode' => $alternate_langcode, '%link' => $url->toString())));
       }
     }
   }
diff --git a/core/modules/node/src/Tests/NodeTypeRenameConfigImportTest.php b/core/modules/node/src/Tests/NodeTypeRenameConfigImportTest.php
index fa7ed6e..667dce7 100644
--- a/core/modules/node/src/Tests/NodeTypeRenameConfigImportTest.php
+++ b/core/modules/node/src/Tests/NodeTypeRenameConfigImportTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\node\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Config\Entity\ConfigEntityStorage;
@@ -104,7 +105,7 @@ public function testConfigurationRename() {
     $this->drupalGet('admin/config/development/configuration');
     foreach ($expected as $rename) {
       $names = $this->configImporter()->getStorageComparer()->extractRenameNames($rename);
-      $this->assertText(String::format('!source_name to !target_name', array('!source_name' => $names['old_name'], '!target_name' => $names['new_name'])));
+      $this->assertText(SafeMarkup::format('!source_name to !target_name', array('!source_name' => $names['old_name'], '!target_name' => $names['new_name'])));
       // Test that the diff link is present for each renamed item.
       $href = \Drupal::urlGenerator()->getPathFromRoute('config.diff', array('source_name' => $names['old_name'], 'target_name' => $names['new_name']));
       $this->assertLinkByHref($href);
diff --git a/core/modules/node/src/Tests/Views/BulkFormAccessTest.php b/core/modules/node/src/Tests/Views/BulkFormAccessTest.php
index d6ea016..36379a3 100644
--- a/core/modules/node/src/Tests/Views/BulkFormAccessTest.php
+++ b/core/modules/node/src/Tests/Views/BulkFormAccessTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\node\Tests\Views;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\node\Entity\Node;
 use Drupal\node\Entity\NodeType;
@@ -92,7 +93,7 @@ public function testNodeEditAccess() {
       'action' => 'node_unpublish_action',
     );
     $this->drupalPostForm('test-node-bulk-form', $edit, t('Apply'));
-    $this->assertRaw(String::format('No access to execute %action on the @entity_type_label %entity_label.', [
+    $this->assertRaw(SafeMarkup::format('No access to execute %action on the @entity_type_label %entity_label.', [
       '%action' => 'Unpublish content',
       '@entity_type_label' => 'Content',
       '%entity_label' => $node->label(),
diff --git a/core/modules/node/src/Tests/Views/FrontPageTest.php b/core/modules/node/src/Tests/Views/FrontPageTest.php
index ed6fd3d..56eb798 100644
--- a/core/modules/node/src/Tests/Views/FrontPageTest.php
+++ b/core/modules/node/src/Tests/Views/FrontPageTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\node\Tests\Views;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Url;
 use Drupal\node\Entity\Node;
@@ -80,7 +81,7 @@ public function testFrontPage() {
     $this->executeView($view);
     $view->preview();
 
-    $this->assertEqual($view->getTitle(), format_string('Welcome to @site_name', array('@site_name' => $site_name)), 'The welcome title is used for the empty view.');
+    $this->assertEqual($view->getTitle(), SafeMarkup::format('Welcome to @site_name', array('@site_name' => $site_name)), 'The welcome title is used for the empty view.');
     $view->destroy();
 
     // Create some nodes on the frontpage view. Add more than 10 nodes in order
diff --git a/core/modules/options/src/Tests/OptionsFieldUITest.php b/core/modules/options/src/Tests/OptionsFieldUITest.php
index ef2b020..4199ae2 100644
--- a/core/modules/options/src/Tests/OptionsFieldUITest.php
+++ b/core/modules/options/src/Tests/OptionsFieldUITest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\options\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\field\Tests\FieldTestBase;
 
@@ -326,7 +327,7 @@ function testNodeDisplay() {
     );
 
     $this->drupalPostForm($this->adminPath, $edit, t('Save field settings'));
-    $this->assertText(format_string('Updated field !field_name field settings.', array('!field_name' => $this->fieldName)), "The 'On' and 'Off' form fields work for boolean fields.");
+    $this->assertText(SafeMarkup::format('Updated field !field_name field settings.', array('!field_name' => $this->fieldName)), "The 'On' and 'Off' form fields work for boolean fields.");
 
     // Select a default value.
     $edit = array(
diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module
index 5717a2a..e96b895 100644
--- a/core/modules/responsive_image/responsive_image.module
+++ b/core/modules/responsive_image/responsive_image.module
@@ -374,7 +374,7 @@ function responsive_image_build_source_attributes(ImageInterface $image, array $
           // this breakpoint should be merged into one srcset and the sizes
           // attribute should be merged as well.
           if (is_null($dimensions['width'])) {
-            throw new \LogicException(String::format('Could not determine image width for @file using image style with ID: @image_style_name. This image style can not be used for a responsive image style mapping using the \'sizes\' attribute.', array('@file' => $image->getSource(), '@image_style_name' => $image_style_name)));
+            throw new \LogicException(SafeMarkup::format('Could not determine image width for @file using image style with ID: @image_style_name. This image style can not be used for a responsive image style mapping using the \'sizes\' attribute.', array('@file' => $image->getSource(), '@image_style_name' => $image_style_name)));
           }
           // Use the image width as key so we can sort the array later on.
           // Images within a srcset should be sorted from small to large, since
diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
index 1059bd4..fea59ff 100644
--- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
+++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\rest\Plugin\rest\resource;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityStorageException;
 use Drupal\rest\Plugin\ResourceBase;
@@ -93,7 +94,7 @@ public function post(EntityInterface $entity = NULL) {
     // and 'update', so the 'edit' operation is used here.
     foreach ($entity->_restSubmittedFields as $key => $field_name) {
       if (!$entity->get($field_name)->access('edit')) {
-        throw new AccessDeniedHttpException(String::format('Access denied on creating field @field', array('@field' => $field_name)));
+        throw new AccessDeniedHttpException(SafeMarkup::format('Access denied on creating field @field', array('@field' => $field_name)));
       }
     }
 
@@ -146,11 +147,11 @@ public function patch(EntityInterface $original_entity, EntityInterface $entity
         continue;
       }
       if ($field->isEmpty() && !$original_entity->get($field_name)->access('delete')) {
-        throw new AccessDeniedHttpException(String::format('Access denied on deleting field @field.', array('@field' => $field_name)));
+        throw new AccessDeniedHttpException(SafeMarkup::format('Access denied on deleting field @field.', array('@field' => $field_name)));
       }
       $original_entity->set($field_name, $field->getValue());
       if (!$original_entity->get($field_name)->access('update')) {
-        throw new AccessDeniedHttpException(String::format('Access denied on updating field @field.', array('@field' => $field_name)));
+        throw new AccessDeniedHttpException(SafeMarkup::format('Access denied on updating field @field.', array('@field' => $field_name)));
       }
     }
 
diff --git a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
index 33a64a7..2e79996 100644
--- a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
+++ b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\search\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 
 use Drupal\Core\Url;
 
@@ -206,7 +207,7 @@ function testSearchModuleDisabling() {
       $this->drupalGet($item['path'], $item['options']);
       foreach ($plugins as $entity_id) {
         $label = $entities[$entity_id]->label();
-        $this->assertText($label, format_string('%label search tab is shown', array('%label' => $label)));
+        $this->assertText($label, SafeMarkup::format('%label search tab is shown', array('%label' => $label)));
       }
     }
   }
diff --git a/core/modules/search/src/Tests/SearchNumberMatchingTest.php b/core/modules/search/src/Tests/SearchNumberMatchingTest.php
index 748596d..7e18425 100644
--- a/core/modules/search/src/Tests/SearchNumberMatchingTest.php
+++ b/core/modules/search/src/Tests/SearchNumberMatchingTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\search\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Language\LanguageInterface;
 
 /**
@@ -82,7 +83,7 @@ function testNumberSearching() {
       $this->drupalPostForm('search/node',
         array('keys' => 'foo'),
         t('Search'));
-      $this->assertNoText($node->label(), format_string('%number: node title not shown in dummy search', array('%number' => $i)));
+      $this->assertNoText($node->label(), SafeMarkup::format('%number: node title not shown in dummy search', array('%number' => $i)));
 
       // Now verify that we can find node i by searching for any of the
       // numbers.
@@ -95,7 +96,7 @@ function testNumberSearching() {
         $this->drupalPostForm('search/node',
           array('keys' => $number),
           t('Search'));
-        $this->assertText($node->label(), format_string('%i: node title shown (search found the node) in search for number %number', array('%i' => $i, '%number' => $number)));
+        $this->assertText($node->label(), SafeMarkup::format('%i: node title shown (search found the node) in search for number %number', array('%i' => $i, '%number' => $number)));
       }
     }
 
diff --git a/core/modules/search/src/Tests/SearchNumbersTest.php b/core/modules/search/src/Tests/SearchNumbersTest.php
index 18e76ba..73c848d 100644
--- a/core/modules/search/src/Tests/SearchNumbersTest.php
+++ b/core/modules/search/src/Tests/SearchNumbersTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\search\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Language\LanguageInterface;
 
 /**
@@ -102,7 +103,7 @@ function testNumberSearching() {
       $this->drupalPostForm('search/node',
         array('keys' => $number),
         t('Search'));
-      $this->assertText($node->label(), format_string('%type: node title shown (search found the node) in search for number %number.', array('%type' => $type, '%number' => $number)));
+      $this->assertText($node->label(), SafeMarkup::format('%type: node title shown (search found the node) in search for number %number.', array('%type' => $type, '%number' => $number)));
     }
   }
 }
diff --git a/core/modules/search/src/Tests/SearchTestBase.php b/core/modules/search/src/Tests/SearchTestBase.php
index bac6974..5f1891f 100644
--- a/core/modules/search/src/Tests/SearchTestBase.php
+++ b/core/modules/search/src/Tests/SearchTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\search\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 use Drupal\Component\Utility\String;
 
@@ -87,10 +88,10 @@ protected function submitGetForm($path, $edit, $submit, $form_html_id = NULL) {
       // We have not found a form which contained all fields of $edit and
       // the submit button.
       foreach ($edit as $name => $value) {
-        $this->fail(String::format('Failed to set field @name to @value', array('@name' => $name, '@value' => $value)));
+        $this->fail(SafeMarkup::format('Failed to set field @name to @value', array('@name' => $name, '@value' => $value)));
       }
-      $this->assertTrue($submit_matches, format_string('Found the @submit button', array('@submit' => $submit)));
-      $this->fail(format_string('Found the requested form fields at @path', array('@path' => $path)));
+      $this->assertTrue($submit_matches, SafeMarkup::format('Found the @submit button', array('@submit' => $submit)));
+      $this->fail(SafeMarkup::format('Found the requested form fields at @path', array('@path' => $path)));
     }
   }
 }
diff --git a/core/modules/serialization/src/Tests/EntitySerializationTest.php b/core/modules/serialization/src/Tests/EntitySerializationTest.php
index 04841a9..4106f15 100644
--- a/core/modules/serialization/src/Tests/EntitySerializationTest.php
+++ b/core/modules/serialization/src/Tests/EntitySerializationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\serialization\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Component\Utility\String;
 use Drupal\user\Entity\User;
@@ -206,7 +207,7 @@ public function testDenormalize() {
 
     foreach (array('json', 'xml') as $type) {
       $denormalized = $this->serializer->denormalize($normalized, $this->entityClass, $type, array('entity_type' => 'entity_test_mulrev'));
-      $this->assertTrue($denormalized instanceof $this->entityClass, String::format('Denormalized entity is an instance of @class', array('@class' => $this->entityClass)));
+      $this->assertTrue($denormalized instanceof $this->entityClass, SafeMarkup::format('Denormalized entity is an instance of @class', array('@class' => $this->entityClass)));
       $this->assertIdentical($denormalized->getEntityTypeId(), $this->entity->getEntityTypeId(), 'Expected entity type found.');
       $this->assertIdentical($denormalized->bundle(), $this->entity->bundle(), 'Expected entity bundle found.');
       $this->assertIdentical($denormalized->uuid(), $this->entity->uuid(), 'Expected entity UUID found.');
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index 1414e0f..fb8123d 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -5,6 +5,7 @@
  * Allows users to manage customizable lists of shortcut links.
  */
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Access\AccessResult;
 use Drupal\Core\Cache\Cache;
@@ -349,7 +350,7 @@ function shortcut_preprocess_page(&$variables) {
         ),
         '#prefix' => '<div class="add-or-remove-shortcuts ' . $link_mode . '-shortcut">',
         '#type' => 'link',
-        '#title' => String::format('<span class="icon"></span><span class="text">@text</span>', array('@text' => $link_text)),
+        '#title' => SafeMarkup::format('<span class="icon"></span><span class="text">@text</span>', array('@text' => $link_text)),
         '#url' => Url::fromRoute($route_name, $route_parameters),
         '#options' => array('query' => $query),
         '#suffix' => '</div>',
diff --git a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
index bf98504..5b3a9d2 100644
--- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
+++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\shortcut\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Url;
 use Drupal\shortcut\Entity\Shortcut;
@@ -69,10 +70,10 @@ public function testShortcutLinkAdd() {
       $this->assertTrue(in_array('internal:' . $test_path, $paths), 'Shortcut created: ' . $test_path);
 
       if (in_array($test_path, $test_cases_non_access)) {
-        $this->assertNoLink($title, String::format('Shortcut link %url not accessible on the page.', ['%url' => $test_path]));
+        $this->assertNoLink($title, SafeMarkup::format('Shortcut link %url not accessible on the page.', ['%url' => $test_path]));
       }
       else {
-        $this->assertLink($title, 0, String::format('Shortcut link %url found on the page.', ['%url' => $test_path]));
+        $this->assertLink($title, 0, SafeMarkup::format('Shortcut link %url found on the page.', ['%url' => $test_path]));
       }
     }
     $saved_set = ShortcutSet::load($set->id());
@@ -322,7 +323,7 @@ private function verifyAccessShortcutsPermissionForEditPages() {
 
     foreach ($edit_paths as $path) {
       $this->drupalGet($path);
-      $message = format_string('Access is denied on %s', array('%s' => $path));
+      $message = SafeMarkup::format('Access is denied on %s', array('%s' => $path));
       $this->assertResponse(403, $message);
     }
   }
diff --git a/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php b/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php
index 9f81cb5..7801031 100644
--- a/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php
+++ b/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\shortcut\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\content_translation\Tests\ContentTranslationUITest;
 use Drupal\Core\Language\Language;
 
@@ -74,7 +75,7 @@ protected function doTestBasicTranslation() {
         $expected_path = \Drupal::urlGenerator()->generateFromRoute('user.page', array(), array('language' => $language));
         $label = $entity->getTranslation($langcode)->label();
         $elements = $this->xpath('//nav[contains(@class, "toolbar-lining")]/ul[@class="menu"]/li/a[contains(@href, :href) and normalize-space(text())=:label]', array(':href' => $expected_path, ':label' => $label));
-        $this->assertTrue(!empty($elements), format_string('Translated @language shortcut link @label found.', array('@label' => $label, '@language' => $language->getName())));
+        $this->assertTrue(!empty($elements), SafeMarkup::format('Translated @language shortcut link @label found.', array('@label' => $label, '@language' => $language->getName())));
       }
     }
   }
diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php
index 9834417..fc9845f 100644
--- a/core/modules/simpletest/src/AssertContentTrait.php
+++ b/core/modules/simpletest/src/AssertContentTrait.php
@@ -8,6 +8,7 @@
 namespace Drupal\simpletest;
 
 use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Xss;
 use Symfony\Component\CssSelector\CssSelector;
@@ -127,7 +128,7 @@ protected function parse() {
       $html_dom = new \DOMDocument();
       @$html_dom->loadHTML('<?xml encoding="UTF-8">' . $this->getRawContent());
       if ($html_dom) {
-        $this->pass(String::format('Valid HTML found on "@path"', array('@path' => $this->getUrl())), 'Browser');
+        $this->pass(SafeMarkup::format('Valid HTML found on "@path"', array('@path' => $this->getUrl())), 'Browser');
         // It's much easier to work with simplexml than DOM, luckily enough
         // we can just simply import our DOM tree.
         $this->elements = simplexml_import_dom($html_dom);
@@ -282,8 +283,9 @@ protected function getAllOptions(\SimpleXMLElement $element) {
    *   Link position counting from zero.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The gorup this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -295,7 +297,7 @@ protected function getAllOptions(\SimpleXMLElement $element) {
    */
   protected function assertLink($label, $index = 0, $message = '', $group = 'Other') {
     $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
-    $message = ($message ? $message : String::format('Link with label %label found.', array('%label' => $label)));
+    $message = ($message ? $message : SafeMarkup::format('Link with label %label found.', array('%label' => $label)));
     return $this->assert(isset($links[$index]), $message, $group);
   }
 
@@ -306,8 +308,9 @@ protected function assertLink($label, $index = 0, $message = '', $group = 'Other
    *   Text between the anchor tags.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -319,7 +322,7 @@ protected function assertLink($label, $index = 0, $message = '', $group = 'Other
    */
   protected function assertNoLink($label, $message = '', $group = 'Other') {
     $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
-    $message = ($message ? $message : String::format('Link with label %label not found.', array('%label' => $label)));
+    $message = ($message ? $message : SafeMarkup::format('Link with label %label not found.', array('%label' => $label)));
     return $this->assert(empty($links), $message, $group);
   }
 
@@ -332,8 +335,9 @@ protected function assertNoLink($label, $message = '', $group = 'Other') {
    *   Link position counting from zero.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -345,7 +349,7 @@ protected function assertNoLink($label, $message = '', $group = 'Other') {
    */
   protected function assertLinkByHref($href, $index = 0, $message = '', $group = 'Other') {
     $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
-    $message = ($message ? $message : String::format('Link containing href %href found.', array('%href' => $href)));
+    $message = ($message ? $message : SafeMarkup::format('Link containing href %href found.', array('%href' => $href)));
     return $this->assert(isset($links[$index]), $message, $group);
   }
 
@@ -356,8 +360,9 @@ protected function assertLinkByHref($href, $index = 0, $message = '', $group = '
    *   The full or partial value of the 'href' attribute of the anchor tag.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -369,7 +374,7 @@ protected function assertLinkByHref($href, $index = 0, $message = '', $group = '
    */
   protected function assertNoLinkByHref($href, $message = '', $group = 'Other') {
     $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
-    $message = ($message ? $message : String::format('No link containing href %href found.', array('%href' => $href)));
+    $message = ($message ? $message : SafeMarkup::format('No link containing href %href found.', array('%href' => $href)));
     return $this->assert(empty($links), $message, $group);
   }
 
@@ -382,8 +387,9 @@ protected function assertNoLinkByHref($href, $message = '', $group = 'Other') {
    *   Raw (HTML) string to look for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -395,7 +401,7 @@ protected function assertNoLinkByHref($href, $message = '', $group = 'Other') {
    */
   protected function assertRaw($raw, $message = '', $group = 'Other') {
     if (!$message) {
-      $message = String::format('Raw "@raw" found', array('@raw' => $raw));
+      $message = SafeMarkup::format('Raw "@raw" found', array('@raw' => $raw));
     }
     return $this->assert(strpos($this->getRawContent(), $raw) !== FALSE, $message, $group);
   }
@@ -409,8 +415,9 @@ protected function assertRaw($raw, $message = '', $group = 'Other') {
    *   Raw (HTML) string to look for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -422,7 +429,7 @@ protected function assertRaw($raw, $message = '', $group = 'Other') {
    */
   protected function assertNoRaw($raw, $message = '', $group = 'Other') {
     if (!$message) {
-      $message = String::format('Raw "@raw" not found', array('@raw' => $raw));
+      $message = SafeMarkup::format('Raw "@raw" not found', array('@raw' => $raw));
     }
     return $this->assert(strpos($this->getRawContent(), $raw) === FALSE, $message, $group);
   }
@@ -436,8 +443,9 @@ protected function assertNoRaw($raw, $message = '', $group = 'Other') {
    *   Raw (HTML) string to look for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -449,7 +457,7 @@ protected function assertNoRaw($raw, $message = '', $group = 'Other') {
    */
   protected function assertEscaped($raw, $message = '', $group = 'Other') {
     if (!$message) {
-      $message = String::format('Escaped "@raw" found', array('@raw' => $raw));
+      $message = SafeMarkup::format('Escaped "@raw" found', array('@raw' => $raw));
     }
     return $this->assert(strpos($this->getRawContent(), String::checkPlain($raw)) !== FALSE, $message, $group);
   }
@@ -464,8 +472,9 @@ protected function assertEscaped($raw, $message = '', $group = 'Other') {
    *   Raw (HTML) string to look for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -477,7 +486,7 @@ protected function assertEscaped($raw, $message = '', $group = 'Other') {
    */
   protected function assertNoEscaped($raw, $message = '', $group = 'Other') {
     if (!$message) {
-      $message = String::format('Escaped "@raw" not found', array('@raw' => $raw));
+      $message = SafeMarkup::format('Escaped "@raw" not found', array('@raw' => $raw));
     }
     return $this->assert(strpos($this->getRawContent(), String::checkPlain($raw)) === FALSE, $message, $group);
   }
@@ -493,8 +502,9 @@ protected function assertNoEscaped($raw, $message = '', $group = 'Other') {
    *   Plain text to look for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -519,8 +529,9 @@ protected function assertText($text, $message = '', $group = 'Other') {
    *   Plain text to look for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -543,8 +554,9 @@ protected function assertNoText($text, $message = '', $group = 'Other') {
    *   Plain text to look for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -559,7 +571,7 @@ protected function assertNoText($text, $message = '', $group = 'Other') {
    */
   protected function assertTextHelper($text, $message = '', $group = 'Other', $not_exists = TRUE) {
     if (!$message) {
-      $message = !$not_exists ? String::format('"@text" found', array('@text' => $text)) : String::format('"@text" not found', array('@text' => $text));
+      $message = !$not_exists ? SafeMarkup::format('"@text" found', array('@text' => $text)) : SafeMarkup::format('"@text" not found', array('@text' => $text));
     }
     return $this->assert($not_exists == (strpos($this->getTextContent(), (string) $text) === FALSE), $message, $group);
   }
@@ -575,8 +587,9 @@ protected function assertTextHelper($text, $message = '', $group = 'Other', $not
    *   Plain text to look for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -601,8 +614,9 @@ protected function assertUniqueText($text, $message = '', $group = 'Other') {
    *   Plain text to look for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -625,8 +639,9 @@ protected function assertNoUniqueText($text, $message = '', $group = 'Other') {
    *   Plain text to look for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -659,8 +674,9 @@ protected function assertUniqueTextHelper($text, $message = '', $group = 'Other'
    *   Perl regex to look for including the regex delimiters.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -672,7 +688,7 @@ protected function assertUniqueTextHelper($text, $message = '', $group = 'Other'
    */
   protected function assertPattern($pattern, $message = '', $group = 'Other') {
     if (!$message) {
-      $message = String::format('Pattern "@pattern" found', array('@pattern' => $pattern));
+      $message = SafeMarkup::format('Pattern "@pattern" found', array('@pattern' => $pattern));
     }
     return $this->assert((bool) preg_match($pattern, $this->getRawContent()), $message, $group);
   }
@@ -684,8 +700,9 @@ protected function assertPattern($pattern, $message = '', $group = 'Other') {
    *   Perl regex to look for including the regex delimiters.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -697,7 +714,7 @@ protected function assertPattern($pattern, $message = '', $group = 'Other') {
    */
   protected function assertNoPattern($pattern, $message = '', $group = 'Other') {
     if (!$message) {
-      $message = String::format('Pattern "@pattern" not found', array('@pattern' => $pattern));
+      $message = SafeMarkup::format('Pattern "@pattern" not found', array('@pattern' => $pattern));
     }
     return $this->assert(!preg_match($pattern, $this->getRawContent()), $message, $group);
   }
@@ -720,7 +737,7 @@ protected function assertNoPattern($pattern, $message = '', $group = 'Other') {
    */
   protected function assertTextPattern($pattern, $message = NULL, $group = 'Other') {
     if (!isset($message)) {
-      $message = String::format('Pattern "@pattern" found', array('@pattern' => $pattern));
+      $message = SafeMarkup::format('Pattern "@pattern" found', array('@pattern' => $pattern));
     }
     return $this->assert((bool) preg_match($pattern, $this->getTextContent()), $message, $group);
   }
@@ -732,8 +749,9 @@ protected function assertTextPattern($pattern, $message = NULL, $group = 'Other'
    *   The string the title should be.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -746,7 +764,7 @@ protected function assertTextPattern($pattern, $message = NULL, $group = 'Other'
   protected function assertTitle($title, $message = '', $group = 'Other') {
     $actual = (string) current($this->xpath('//title'));
     if (!$message) {
-      $message = String::format('Page title @actual is equal to @expected.', array(
+      $message = SafeMarkup::format('Page title @actual is equal to @expected.', array(
         '@actual' => var_export($actual, TRUE),
         '@expected' => var_export($title, TRUE),
       ));
@@ -761,8 +779,9 @@ protected function assertTitle($title, $message = '', $group = 'Other') {
    *   The string the title should not be.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -775,7 +794,7 @@ protected function assertTitle($title, $message = '', $group = 'Other') {
   protected function assertNoTitle($title, $message = '', $group = 'Other') {
     $actual = (string) current($this->xpath('//title'));
     if (!$message) {
-      $message = String::format('Page title @actual is not equal to @unexpected.', array(
+      $message = SafeMarkup::format('Page title @actual is not equal to @unexpected.', array(
         '@actual' => var_export($actual, TRUE),
         '@unexpected' => var_export($title, TRUE),
       ));
@@ -794,8 +813,9 @@ protected function assertNoTitle($title, $message = '', $group = 'Other') {
    *   The expected themed output string.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -815,7 +835,7 @@ protected function assertThemeOutput($callback, array $variables = array(), $exp
     if (!$message) {
       $message = '%callback rendered correctly.';
     }
-    $message = format_string($message, array('%callback' => 'theme_' . $callback . '()'));
+    $message = SafeMarkup::format($message, array('%callback' => 'theme_' . $callback . '()'));
     return $this->assertIdentical($output, $expected, $message, $group);
   }
 
@@ -830,8 +850,9 @@ protected function assertThemeOutput($callback, array $variables = array(), $exp
    *   exists.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -911,8 +932,9 @@ protected function getSelectedItem(\SimpleXMLElement $element) {
    *   page does not match it.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -951,8 +973,9 @@ protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '', $g
    *   exists.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -965,12 +988,12 @@ protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '', $g
   protected function assertFieldByName($name, $value = NULL, $message = NULL, $group = 'Browser') {
     if (!isset($message)) {
       if (!isset($value)) {
-        $message = String::format('Found field with name @name', array(
+        $message = SafeMarkup::format('Found field with name @name', array(
           '@name' => var_export($name, TRUE),
         ));
       }
       else {
-        $message = String::format('Found field with name @name and value @value', array(
+        $message = SafeMarkup::format('Found field with name @name and value @value', array(
           '@name' => var_export($name, TRUE),
           '@value' => var_export($value, TRUE),
         ));
@@ -991,8 +1014,9 @@ protected function assertFieldByName($name, $value = NULL, $message = NULL, $gro
    *   default value ('') asserts that the field value is not an empty string.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1003,7 +1027,7 @@ protected function assertFieldByName($name, $value = NULL, $message = NULL, $gro
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertNoFieldByName($name, $value = '', $message = '', $group = 'Browser') {
-    return $this->assertNoFieldByXPath($this->constructFieldXpath('name', $name), $value, $message ? $message : String::format('Did not find field by name @name', array('@name' => $name)), $group);
+    return $this->assertNoFieldByXPath($this->constructFieldXpath('name', $name), $value, $message ? $message : SafeMarkup::format('Did not find field by name @name', array('@name' => $name)), $group);
   }
 
   /**
@@ -1018,8 +1042,9 @@ protected function assertNoFieldByName($name, $value = '', $message = '', $group
    *   string.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1030,7 +1055,7 @@ protected function assertNoFieldByName($name, $value = '', $message = '', $group
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertFieldById($id, $value = '', $message = '', $group = 'Browser') {
-    return $this->assertFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : String::format('Found field by id @id', array('@id' => $id)), $group);
+    return $this->assertFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : SafeMarkup::format('Found field by id @id', array('@id' => $id)), $group);
   }
 
   /**
@@ -1045,8 +1070,9 @@ protected function assertFieldById($id, $value = '', $message = '', $group = 'Br
    *   value ('') asserts that the field value is not an empty string.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1057,7 +1083,7 @@ protected function assertFieldById($id, $value = '', $message = '', $group = 'Br
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertNoFieldById($id, $value = '', $message = '', $group = 'Browser') {
-    return $this->assertNoFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : String::format('Did not find field by id @id', array('@id' => $id)), $group);
+    return $this->assertNoFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : SafeMarkup::format('Did not find field by id @id', array('@id' => $id)), $group);
   }
 
   /**
@@ -1067,8 +1093,9 @@ protected function assertNoFieldById($id, $value = '', $message = '', $group = '
    *   ID of field to assert.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1080,7 +1107,7 @@ protected function assertNoFieldById($id, $value = '', $message = '', $group = '
    */
   protected function assertFieldChecked($id, $message = '', $group = 'Browser') {
     $elements = $this->xpath('//input[@id=:id]', array(':id' => $id));
-    return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), $message ? $message : String::format('Checkbox field @id is checked.', array('@id' => $id)), $group);
+    return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), $message ? $message : SafeMarkup::format('Checkbox field @id is checked.', array('@id' => $id)), $group);
   }
 
   /**
@@ -1090,8 +1117,9 @@ protected function assertFieldChecked($id, $message = '', $group = 'Browser') {
    *   ID of field to assert.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1103,7 +1131,7 @@ protected function assertFieldChecked($id, $message = '', $group = 'Browser') {
    */
   protected function assertNoFieldChecked($id, $message = '', $group = 'Browser') {
     $elements = $this->xpath('//input[@id=:id]', array(':id' => $id));
-    return $this->assertTrue(isset($elements[0]) && empty($elements[0]['checked']), $message ? $message : String::format('Checkbox field @id is not checked.', array('@id' => $id)), $group);
+    return $this->assertTrue(isset($elements[0]) && empty($elements[0]['checked']), $message ? $message : SafeMarkup::format('Checkbox field @id is not checked.', array('@id' => $id)), $group);
   }
 
   /**
@@ -1115,8 +1143,9 @@ protected function assertNoFieldChecked($id, $message = '', $group = 'Browser')
    *   Option to assert.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1128,7 +1157,7 @@ protected function assertNoFieldChecked($id, $message = '', $group = 'Browser')
    */
   protected function assertOption($id, $option, $message = '', $group = 'Browser') {
     $options = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($options[0]), $message ? $message : String::format('Option @option for field @id exists.', array('@option' => $option, '@id' => $id)), $group);
+    return $this->assertTrue(isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @id exists.', array('@option' => $option, '@id' => $id)), $group);
   }
 
   /**
@@ -1140,8 +1169,9 @@ protected function assertOption($id, $option, $message = '', $group = 'Browser')
    *   Option to assert.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1154,7 +1184,7 @@ protected function assertOption($id, $option, $message = '', $group = 'Browser')
   protected function assertNoOption($id, $option, $message = '', $group = 'Browser') {
     $selects = $this->xpath('//select[@id=:id]', array(':id' => $id));
     $options = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message ? $message : String::format('Option @option for field @id does not exist.', array('@option' => $option, '@id' => $id)), $group);
+    return $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @id does not exist.', array('@option' => $option, '@id' => $id)), $group);
   }
 
   /**
@@ -1166,8 +1196,9 @@ protected function assertNoOption($id, $option, $message = '', $group = 'Browser
    *   Option to assert.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1181,7 +1212,7 @@ protected function assertNoOption($id, $option, $message = '', $group = 'Browser
    */
   protected function assertOptionSelected($id, $option, $message = '', $group = 'Browser') {
     $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : String::format('Option @option for field @id is selected.', array('@option' => $option, '@id' => $id)), $group);
+    return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : SafeMarkup::format('Option @option for field @id is selected.', array('@option' => $option, '@id' => $id)), $group);
   }
 
   /**
@@ -1193,8 +1224,9 @@ protected function assertOptionSelected($id, $option, $message = '', $group = 'B
    *   Option to assert.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1206,7 +1238,7 @@ protected function assertOptionSelected($id, $option, $message = '', $group = 'B
    */
   protected function assertNoOptionSelected($id, $option, $message = '', $group = 'Browser') {
     $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($elements[0]) && empty($elements[0]['selected']), $message ? $message : String::format('Option @option for field @id is not selected.', array('@option' => $option, '@id' => $id)), $group);
+    return $this->assertTrue(isset($elements[0]) && empty($elements[0]['selected']), $message ? $message : SafeMarkup::format('Option @option for field @id is not selected.', array('@option' => $option, '@id' => $id)), $group);
   }
 
   /**
@@ -1216,8 +1248,9 @@ protected function assertNoOptionSelected($id, $option, $message = '', $group =
    *   Name or ID of field to assert.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1238,8 +1271,9 @@ protected function assertField($field, $message = '', $group = 'Other') {
    *   Name or ID of field to assert.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1258,8 +1292,9 @@ protected function assertNoField($field, $message = '', $group = 'Other') {
    *
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
+   *   variables in the message text, not t(). If left blank, a default message
+   *   will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -1281,7 +1316,7 @@ protected function assertNoDuplicateIds($message = '', $group = 'Other', $ids_to
     foreach ($this->xpath('//*[@id]') as $element) {
       $id = (string) $element['id'];
       if (isset($seen_ids[$id]) && !in_array($id, $ids_to_skip)) {
-        $this->fail(String::format('The HTML ID %id is unique.', array('%id' => $id)), $group);
+        $this->fail(SafeMarkup::format('The HTML ID %id is unique.', array('%id' => $id)), $group);
         $status = FALSE;
       }
       $seen_ids[$id] = TRUE;
diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php
index abc1f20..bd98425 100644
--- a/core/modules/simpletest/src/KernelTestBase.php
+++ b/core/modules/simpletest/src/KernelTestBase.php
@@ -370,13 +370,13 @@ public function containerBuild(ContainerBuilder $container) {
   protected function installConfig(array $modules) {
     foreach ($modules as $module) {
       if (!$this->container->get('module_handler')->moduleExists($module)) {
-        throw new \RuntimeException(format_string("'@module' module is not enabled.", array(
+        throw new \RuntimeException(SafeMarkup::format("'@module' module is not enabled.", array(
           '@module' => $module,
         )));
       }
       \Drupal::service('config.installer')->installDefaultConfig('module', $module);
     }
-    $this->pass(format_string('Installed default config: %modules.', array(
+    $this->pass(SafeMarkup::format('Installed default config: %modules.', array(
       '%modules' => implode(', ', $modules),
     )));
   }
@@ -400,7 +400,7 @@ protected function installSchema($module, $tables) {
     // behavior and non-reproducible test failures, we only allow the schema of
     // explicitly loaded/enabled modules to be installed.
     if (!$this->container->get('module_handler')->moduleExists($module)) {
-      throw new \RuntimeException(format_string("'@module' module is not enabled.", array(
+      throw new \RuntimeException(SafeMarkup::format("'@module' module is not enabled.", array(
         '@module' => $module,
       )));
     }
@@ -408,7 +408,7 @@ protected function installSchema($module, $tables) {
     foreach ($tables as $table) {
       $schema = drupal_get_schema_unprocessed($module, $table);
       if (empty($schema)) {
-        throw new \RuntimeException(format_string("Unknown '@table' table schema in '@module' module.", array(
+        throw new \RuntimeException(SafeMarkup::format("Unknown '@table' table schema in '@module' module.", array(
           '@module' => $module,
           '@table' => $table,
         )));
@@ -419,7 +419,7 @@ protected function installSchema($module, $tables) {
     // would not know of/return the schema otherwise.
     // @todo Refactor Schema API to make this obsolete.
     drupal_get_schema(NULL, TRUE);
-    $this->pass(format_string('Installed %module tables: %tables.', array(
+    $this->pass(SafeMarkup::format('Installed %module tables: %tables.', array(
       '%tables' => '{' . implode('}, {', $tables) . '}',
       '%module' => $module,
     )));
@@ -448,7 +448,7 @@ protected function installEntitySchema($entity_type_id) {
       $all_tables_exist = TRUE;
       foreach ($tables as $table) {
         if (!$db_schema->tableExists($table)) {
-          $this->fail(String::format('Installed entity type table for the %entity_type entity type: %table', array(
+          $this->fail(SafeMarkup::format('Installed entity type table for the %entity_type entity type: %table', array(
             '%entity_type' => $entity_type_id,
             '%table' => $table,
           )));
@@ -456,7 +456,7 @@ protected function installEntitySchema($entity_type_id) {
         }
       }
       if ($all_tables_exist) {
-        $this->pass(String::format('Installed entity type tables for the %entity_type entity type: %tables', array(
+        $this->pass(SafeMarkup::format('Installed entity type tables for the %entity_type entity type: %tables', array(
           '%entity_type' => $entity_type_id,
           '%tables' => '{' . implode('}, {', $tables) . '}',
         )));
@@ -496,7 +496,7 @@ protected function enableModules(array $modules) {
     // Note that the kernel has rebuilt the container; this $module_handler is
     // no longer the $module_handler instance from above.
     $this->container->get('module_handler')->reload();
-    $this->pass(format_string('Enabled modules: %modules.', array(
+    $this->pass(SafeMarkup::format('Enabled modules: %modules.', array(
       '%modules' => implode(', ', $modules),
     )));
   }
@@ -530,7 +530,7 @@ protected function disableModules(array $modules) {
     // no longer the $module_handler instance from above.
     $module_handler = $this->container->get('module_handler');
     $module_handler->reload();
-    $this->pass(format_string('Disabled modules: %modules.', array(
+    $this->pass(SafeMarkup::format('Disabled modules: %modules.', array(
       '%modules' => implode(', ', $modules),
     )));
   }
diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php
index b621140..b4dbf39 100644
--- a/core/modules/simpletest/src/TestBase.php
+++ b/core/modules/simpletest/src/TestBase.php
@@ -371,7 +371,7 @@ protected function storeAssertion(array $assertion) {
    *   TRUE is a synonym for 'pass', FALSE for 'fail'.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -555,7 +555,7 @@ protected function getAssertionCall() {
    *   The value on which the assertion is to be done.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -568,7 +568,7 @@ protected function getAssertionCall() {
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertTrue($value, $message = '', $group = 'Other') {
-    return $this->assert((bool) $value, $message ? $message : String::format('Value @value is TRUE.', array('@value' => var_export($value, TRUE))), $group);
+    return $this->assert((bool) $value, $message ? $message : SafeMarkup::format('Value @value is TRUE.', array('@value' => var_export($value, TRUE))), $group);
   }
 
   /**
@@ -580,7 +580,7 @@ protected function assertTrue($value, $message = '', $group = 'Other') {
    *   The value on which the assertion is to be done.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -593,7 +593,7 @@ protected function assertTrue($value, $message = '', $group = 'Other') {
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertFalse($value, $message = '', $group = 'Other') {
-    return $this->assert(!$value, $message ? $message : String::format('Value @value is FALSE.', array('@value' => var_export($value, TRUE))), $group);
+    return $this->assert(!$value, $message ? $message : SafeMarkup::format('Value @value is FALSE.', array('@value' => var_export($value, TRUE))), $group);
   }
 
   /**
@@ -603,7 +603,7 @@ protected function assertFalse($value, $message = '', $group = 'Other') {
    *   The value on which the assertion is to be done.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -616,7 +616,7 @@ protected function assertFalse($value, $message = '', $group = 'Other') {
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertNull($value, $message = '', $group = 'Other') {
-    return $this->assert(!isset($value), $message ? $message : String::format('Value @value is NULL.', array('@value' => var_export($value, TRUE))), $group);
+    return $this->assert(!isset($value), $message ? $message : SafeMarkup::format('Value @value is NULL.', array('@value' => var_export($value, TRUE))), $group);
   }
 
   /**
@@ -626,7 +626,7 @@ protected function assertNull($value, $message = '', $group = 'Other') {
    *   The value on which the assertion is to be done.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -639,7 +639,7 @@ protected function assertNull($value, $message = '', $group = 'Other') {
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertNotNull($value, $message = '', $group = 'Other') {
-    return $this->assert(isset($value), $message ? $message : String::format('Value @value is not NULL.', array('@value' => var_export($value, TRUE))), $group);
+    return $this->assert(isset($value), $message ? $message : SafeMarkup::format('Value @value is not NULL.', array('@value' => var_export($value, TRUE))), $group);
   }
 
   /**
@@ -651,7 +651,7 @@ protected function assertNotNull($value, $message = '', $group = 'Other') {
    *   The second value to check.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -664,7 +664,7 @@ protected function assertNotNull($value, $message = '', $group = 'Other') {
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertEqual($first, $second, $message = '', $group = 'Other') {
-    return $this->assert($first == $second, $message ? $message : String::format('Value @first is equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
+    return $this->assert($first == $second, $message ? $message : SafeMarkup::format('Value @first is equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
   }
 
   /**
@@ -676,7 +676,7 @@ protected function assertEqual($first, $second, $message = '', $group = 'Other')
    *   The second value to check.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -689,7 +689,7 @@ protected function assertEqual($first, $second, $message = '', $group = 'Other')
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertNotEqual($first, $second, $message = '', $group = 'Other') {
-    return $this->assert($first != $second, $message ? $message : String::format('Value @first is not equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
+    return $this->assert($first != $second, $message ? $message : SafeMarkup::format('Value @first is not equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
   }
 
   /**
@@ -701,7 +701,7 @@ protected function assertNotEqual($first, $second, $message = '', $group = 'Othe
    *   The second value to check.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -714,7 +714,7 @@ protected function assertNotEqual($first, $second, $message = '', $group = 'Othe
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertIdentical($first, $second, $message = '', $group = 'Other') {
-    return $this->assert($first === $second, $message ? $message : String::format('Value @first is identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
+    return $this->assert($first === $second, $message ? $message : SafeMarkup::format('Value @first is identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
   }
 
   /**
@@ -726,7 +726,7 @@ protected function assertIdentical($first, $second, $message = '', $group = 'Oth
    *   The second value to check.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -739,7 +739,7 @@ protected function assertIdentical($first, $second, $message = '', $group = 'Oth
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertNotIdentical($first, $second, $message = '', $group = 'Other') {
-    return $this->assert($first !== $second, $message ? $message : String::format('Value @first is not identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
+    return $this->assert($first !== $second, $message ? $message : SafeMarkup::format('Value @first is not identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
   }
 
   /**
@@ -751,7 +751,7 @@ protected function assertNotIdentical($first, $second, $message = '', $group = '
    *   The second object to check.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -764,7 +764,7 @@ protected function assertNotIdentical($first, $second, $message = '', $group = '
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertIdenticalObject($object1, $object2, $message = '', $group = 'Other') {
-    $message = $message ?: String::format('!object1 is identical to !object2', array(
+    $message = $message ?: SafeMarkup::format('!object1 is identical to !object2', array(
       '!object1' => var_export($object1, TRUE),
       '!object2' => var_export($object2, TRUE),
     ));
@@ -795,7 +795,7 @@ protected function assertNoErrorsLogged() {
    *
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -816,7 +816,7 @@ protected function pass($message = NULL, $group = 'Other') {
    *
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -837,7 +837,7 @@ protected function fail($message = NULL, $group = 'Other') {
    *
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use \Drupal\Component\Utility\String::format() to embed
+   *   messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
    *   variables in the message text, not t(). If left blank, a default message
    *   will be displayed.
    * @param $group
@@ -1400,7 +1400,7 @@ protected function exceptionHandler($exception) {
     // message through \Drupal\Component\Utility\String::checkPlain().
     $decoded_exception = Error::decodeException($exception);
     unset($decoded_exception['backtrace']);
-    $message = String::format('%type: !message in %function (line %line of %file). <pre class="backtrace">!backtrace</pre>', $decoded_exception + array(
+    $message = SafeMarkup::format('%type: !message in %function (line %line of %file). <pre class="backtrace">!backtrace</pre>', $decoded_exception + array(
       '!backtrace' => Error::formatBacktrace($verbose_backtrace),
     ));
     $this->error($message, 'Uncaught exception', Error::getLastCaller($backtrace));
diff --git a/core/modules/simpletest/src/Tests/MailCaptureTest.php b/core/modules/simpletest/src/Tests/MailCaptureTest.php
index 00b4be8..34b518e 100644
--- a/core/modules/simpletest/src/Tests/MailCaptureTest.php
+++ b/core/modules/simpletest/src/Tests/MailCaptureTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\simpletest\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -45,7 +46,7 @@ function testMailSend() {
     // Assert that the email was sent by iterating over the message properties
     // and ensuring that they are captured intact.
     foreach ($message as $field => $value) {
-      $this->assertMail($field, $value, format_string('The email was sent and the value for property @field is intact.', array('@field' => $field)), 'Email');
+      $this->assertMail($field, $value, SafeMarkup::format('The email was sent and the value for property @field is intact.', array('@field' => $field)), 'Email');
     }
 
     // Send additional emails so more than one email is captured.
diff --git a/core/modules/simpletest/src/Tests/SimpleTestTest.php b/core/modules/simpletest/src/Tests/SimpleTestTest.php
index 20b5a75..b92dfb3 100644
--- a/core/modules/simpletest/src/Tests/SimpleTestTest.php
+++ b/core/modules/simpletest/src/Tests/SimpleTestTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\simpletest\Tests;
 
 use Drupal\Component\Utility\Crypt;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -291,7 +292,7 @@ function assertAssertion($message, $type, $status, $file, $function) {
         break;
       }
     }
-    return $this->assertTrue($found, format_string('Found assertion {"@message", "@type", "@status", "@file", "@function"}.', array('@message' => $message, '@type' => $type, '@status' => $status, "@file" => $file, "@function" => $function)));
+    return $this->assertTrue($found, SafeMarkup::format('Found assertion {"@message", "@type", "@status", "@file", "@function"}.', array('@message' => $message, '@type' => $type, '@status' => $status, "@file" => $file, "@function" => $function)));
   }
 
   /**
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 7088456..eb014d1 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -292,7 +292,7 @@ protected function drupalCreateContentType(array $values = array()) {
     node_add_body_field($type);
     \Drupal::service('router.builder')->rebuild();
 
-    $this->assertEqual($status, SAVED_NEW, String::format('Created content type %type.', array('%type' => $type->id())));
+    $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created content type %type.', array('%type' => $type->id())));
 
     return $type;
   }
@@ -419,7 +419,7 @@ protected function drupalPlaceBlock($plugin_id, array $settings = array()) {
    */
   protected function assertBlockAppears(Block $block) {
     $result = $this->findBlockInstance($block);
-    $this->assertTrue(!empty($result), format_string('Ensure the block @id appears on the page', array('@id' => $block->id())));
+    $this->assertTrue(!empty($result), SafeMarkup::format('Ensure the block @id appears on the page', array('@id' => $block->id())));
   }
 
   /**
@@ -430,7 +430,7 @@ protected function assertBlockAppears(Block $block) {
    */
   protected function assertNoBlockAppears(Block $block) {
     $result = $this->findBlockInstance($block);
-    $this->assertFalse(!empty($result), format_string('Ensure the block @id does not appear on the page', array('@id' => $block->id())));
+    $this->assertFalse(!empty($result), SafeMarkup::format('Ensure the block @id does not appear on the page', array('@id' => $block->id())));
   }
 
   /**
@@ -554,7 +554,7 @@ protected function drupalCreateUser(array $permissions = array(), $name = NULL)
     $account = entity_create('user', $edit);
     $account->save();
 
-    $this->assertTrue($account->id(), String::format('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), 'User login');
+    $this->assertTrue($account->id(), SafeMarkup::format('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), 'User login');
     if (!$account->id()) {
       return FALSE;
     }
@@ -607,7 +607,7 @@ protected function drupalCreateRole(array $permissions, $rid = NULL, $name = NUL
     }
     $result = $role->save();
 
-    $this->assertIdentical($result, SAVED_NEW, String::format('Created role ID @rid with name @name.', array(
+    $this->assertIdentical($result, SAVED_NEW, SafeMarkup::format('Created role ID @rid with name @name.', array(
       '@name' => var_export($role->label(), TRUE),
       '@rid' => var_export($role->id(), TRUE),
     )), 'Role');
@@ -619,10 +619,10 @@ protected function drupalCreateRole(array $permissions, $rid = NULL, $name = NUL
         $assigned_permissions = Role::load($role->id())->getPermissions();
         $missing_permissions = array_diff($permissions, $assigned_permissions);
         if (!$missing_permissions) {
-          $this->pass(String::format('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), 'Role');
+          $this->pass(SafeMarkup::format('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), 'Role');
         }
         else {
-          $this->fail(String::format('Failed to create permissions: @perms', array('@perms' => implode(', ', $missing_permissions))), 'Role');
+          $this->fail(SafeMarkup::format('Failed to create permissions: @perms', array('@perms' => implode(', ', $missing_permissions))), 'Role');
         }
       }
       return $role->id();
@@ -646,7 +646,7 @@ protected function checkPermissions(array $permissions) {
     $valid = TRUE;
     foreach ($permissions as $permission) {
       if (!in_array($permission, $available)) {
-        $this->fail(String::format('Invalid permission %permission.', array('%permission' => $permission)), 'Role');
+        $this->fail(SafeMarkup::format('Invalid permission %permission.', array('%permission' => $permission)), 'Role');
         $valid = FALSE;
       }
     }
@@ -695,7 +695,7 @@ protected function drupalLogin(AccountInterface $account) {
     if (isset($this->sessionId)) {
       $account->session_id = $this->sessionId;
     }
-    $pass = $this->assert($this->drupalUserIsLoggedIn($account), format_string('User %name successfully logged in.', array('%name' => $account->getUsername())), 'User login');
+    $pass = $this->assert($this->drupalUserIsLoggedIn($account), SafeMarkup::format('User %name successfully logged in.', array('%name' => $account->getUsername())), 'User login');
     if ($pass) {
       $this->loggedInUser = $account;
       $this->container->get('current_user')->setAccount($account);
@@ -939,7 +939,7 @@ protected function setUp() {
       $modules = array_unique($modules);
       try {
         $success = $container->get('module_installer')->install($modules, TRUE);
-        $this->assertTrue($success, String::format('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
+        $this->assertTrue($success, SafeMarkup::format('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
       }
       catch (\Drupal\Core\Extension\MissingDependencyException $e) {
         // The exception message has all the details.
@@ -1396,7 +1396,7 @@ protected function curlExec($curl_options, $redirect = FALSE) {
       '@status' => $status,
       '!length' => format_size(strlen($this->getRawContent()))
     );
-    $message = String::format('!method @url returned @status (!length).', $message_vars);
+    $message = SafeMarkup::format('!method @url returned @status (!length).', $message_vars);
     $this->assertTrue($this->getRawContent() !== FALSE, $message, 'Browser');
     return $this->getRawContent();
   }
@@ -1716,12 +1716,12 @@ protected function drupalPostForm($path, $edit, $submit, array $options = array(
       }
       // We have not found a form which contained all fields of $edit.
       foreach ($edit as $name => $value) {
-        $this->fail(String::format('Failed to set field @name to @value', array('@name' => $name, '@value' => $value)));
+        $this->fail(SafeMarkup::format('Failed to set field @name to @value', array('@name' => $name, '@value' => $value)));
       }
       if (!$ajax && isset($submit)) {
-        $this->assertTrue($submit_matches, format_string('Found the @submit button', array('@submit' => $submit)));
+        $this->assertTrue($submit_matches, SafeMarkup::format('Found the @submit button', array('@submit' => $submit)));
       }
-      $this->fail(format_string('Found the requested form fields at @path', array('@path' => $path)));
+      $this->fail(SafeMarkup::format('Found the requested form fields at @path', array('@path' => $path)));
     }
   }
 
@@ -2302,10 +2302,10 @@ protected function clickLink($label, $index = 0) {
     $urls = $this->xpath('//a[normalize-space()=:label]', array(':label' => $label));
     if (isset($urls[$index])) {
       $url_target = $this->getAbsoluteUrl($urls[$index]['href']);
-      $this->pass(String::format('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser');
+      $this->pass(SafeMarkup::format('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser');
       return $this->drupalGet($url_target);
     }
-    $this->fail(String::format('Link %label does not exist on @url_before', array('%label' => $label, '@url_before' => $url_before)), 'Browser');
+    $this->fail(SafeMarkup::format('Link %label does not exist on @url_before', array('%label' => $label, '@url_before' => $url_before)), 'Browser');
     return FALSE;
   }
 
@@ -2465,8 +2465,8 @@ protected function drupalGetMails($filter = array()) {
    *   (optional) Any additional options to pass for $path to the url generator.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use SafeMarkup::format() to embed variables in the message text,
+   *   not t(). If left blank, a default message will be displayed.
    * @param $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -2485,7 +2485,7 @@ protected function assertUrl($path, array $options = array(), $message = '', $gr
       $url = $this->container->get('url_generator')->generateFromPath($path, $options);
     }
     if (!$message) {
-      $message = String::format('Expected @url matches current URL (@current_url).', array(
+      $message = SafeMarkup::format('Expected @url matches current URL (@current_url).', array(
         '@url' => var_export($url, TRUE),
         '@current_url' => $this->getUrl(),
       ));
@@ -2505,8 +2505,8 @@ protected function assertUrl($path, array $options = array(), $message = '', $gr
    *   of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use SafeMarkup::format() to embed variables in the message text,
+   *   not t(). If left blank, a default message will be displayed.
    * @param $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -2519,7 +2519,7 @@ protected function assertUrl($path, array $options = array(), $message = '', $gr
   protected function assertResponse($code, $message = '', $group = 'Browser') {
     $curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
     $match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
-    return $this->assertTrue($match, $message ? $message : String::format('HTTP response expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), $group);
+    return $this->assertTrue($match, $message ? $message : SafeMarkup::format('HTTP response expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), $group);
   }
 
   /**
@@ -2530,8 +2530,8 @@ protected function assertResponse($code, $message = '', $group = 'Browser') {
    *   of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use SafeMarkup::format() to embed variables in the message text,
+   *   not t(). If left blank, a default message will be displayed.
    * @param $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -2544,7 +2544,7 @@ protected function assertResponse($code, $message = '', $group = 'Browser') {
   protected function assertNoResponse($code, $message = '', $group = 'Browser') {
     $curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
     $match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
-    return $this->assertFalse($match, $message ? $message : String::format('HTTP response not expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), $group);
+    return $this->assertFalse($match, $message ? $message : SafeMarkup::format('HTTP response not expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), $group);
   }
 
   /**
@@ -2559,8 +2559,8 @@ protected function assertNoResponse($code, $message = '', $group = 'Browser') {
    *   Value of the field to assert.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use SafeMarkup::format() to embed variables in the message text,
+   *   not t(). If left blank, a default message will be displayed.
    * @param $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -2587,8 +2587,8 @@ protected function assertMail($name, $value = '', $message = '', $group = 'Email
    *   Number of emails to search for string, starting with most recent.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use SafeMarkup::format() to embed variables in the message text,
+   *   not t(). If left blank, a default message will be displayed.
    * @param $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -2613,7 +2613,7 @@ protected function assertMailString($field_name, $string, $email_depth, $message
       }
     }
     if (!$message) {
-      $message = format_string('Expected text found in @field of email message: "@expected".', array('@field' => $field_name, '@expected' => $string));
+      $message = SafeMarkup::format('Expected text found in @field of email message: "@expected".', array('@field' => $field_name, '@expected' => $string));
     }
     return $this->assertTrue($string_found, $message, $group);
   }
@@ -2627,8 +2627,8 @@ protected function assertMailString($field_name, $string, $email_depth, $message
    *   Pattern to search for.
    * @param $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
-   *   t(). If left blank, a default message will be displayed.
+   *   messages: use SafeMarkup::format() to embed variables in the message text,
+   *   not t(). If left blank, a default message will be displayed.
    * @param $group
    *   (optional) The group this message is in, which is displayed in a column
    *   in test output. Use 'Debug' to indicate this is debugging output. Do not
@@ -2643,7 +2643,7 @@ protected function assertMailPattern($field_name, $regex, $message = '', $group
     $mail = end($mails);
     $regex_found = preg_match("/$regex/", $mail[$field_name]);
     if (!$message) {
-      $message = format_string('Expected text found in @field of email message: "@expected".', array('@field' => $field_name, '@expected' => $regex));
+      $message = SafeMarkup::format('Expected text found in @field of email message: "@expected".', array('@field' => $field_name, '@expected' => $regex));
     }
     return $this->assertTrue($regex_found, $message, $group);
   }
diff --git a/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php
index d481f01..93ea929 100644
--- a/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php
+++ b/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\statistics\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Generates text using placeholders for dummy content to check statistics token
@@ -50,7 +51,7 @@ function testStatisticsTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = \Drupal::token()->replace($input, array('node' => $node), array('langcode' => $language_interface->getId()));
-      $this->assertEqual($output, $expected, format_string('Statistics token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Statistics token %token replaced.', array('%token' => $input)));
     }
   }
 }
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php
index 51d79aa..6e093e7 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php
@@ -38,7 +38,7 @@ protected function arguments() {
    */
   protected function validateArguments(array $arguments) {
     if (!in_array($arguments['extension'], $this->getToolkit()->getSupportedExtensions())) {
-      throw new \InvalidArgumentException(String::format("Invalid extension (@value) specified for the image 'convert' operation", array('@value' => $arguments['extension'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid extension (@value) specified for the image 'convert' operation", array('@value' => $arguments['extension'])));
     }
     return $arguments;
   }
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php
index 126f53c..5c0136d 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php
@@ -8,6 +8,7 @@
 namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
 
 use Drupal\Component\Utility\Color;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -53,7 +54,7 @@ protected function arguments() {
   protected function validateArguments(array $arguments) {
     // Assure extension is supported.
     if (!in_array($arguments['extension'], $this->getToolkit()->getSupportedExtensions())) {
-      throw new \InvalidArgumentException(String::format("Invalid extension (@value) specified for the image 'convert' operation", array('@value' => $arguments['extension'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid extension (@value) specified for the image 'convert' operation", array('@value' => $arguments['extension'])));
     }
 
     // Assure integers for width and height.
@@ -62,15 +63,15 @@ protected function validateArguments(array $arguments) {
 
     // Fail when width or height are 0 or negative.
     if ($arguments['width'] <= 0) {
-      throw new \InvalidArgumentException(String::format("Invalid width (@value) specified for the image 'create_new' operation", array('@value' => $arguments['width'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid width (@value) specified for the image 'create_new' operation", array('@value' => $arguments['width'])));
     }
     if ($arguments['height'] <= 0) {
-      throw new \InvalidArgumentException(String::format("Invalid height (@value) specified for the image 'create_new' operation", array('@value' => $arguments['height'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid height (@value) specified for the image 'create_new' operation", array('@value' => $arguments['height'])));
     }
 
     // Assure transparent color is a valid hex string.
     if ($arguments['transparent_color'] && !Color::validateHex($arguments['transparent_color'])) {
-      throw new \InvalidArgumentException(String::format("Invalid transparent color (@value) specified for the image 'create_new' operation", array('@value' => $arguments['transparent_color'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid transparent color (@value) specified for the image 'create_new' operation", array('@value' => $arguments['transparent_color'])));
     }
 
     return $arguments;
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php
index fbda1ec..1e76e53 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -67,10 +68,10 @@ protected function validateArguments(array $arguments) {
 
     // Fail when width or height are 0 or negative.
     if ($arguments['width'] <= 0) {
-      throw new \InvalidArgumentException(String::format("Invalid width (@value) specified for the image 'crop' operation", array('@value' => $arguments['width'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid width (@value) specified for the image 'crop' operation", array('@value' => $arguments['width'])));
     }
     if ($arguments['height'] <= 0) {
-      throw new \InvalidArgumentException(String::format("Invalid height (@value) specified for the image 'crop' operation", array('@value' => $arguments['height'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid height (@value) specified for the image 'crop' operation", array('@value' => $arguments['height'])));
     }
 
     return $arguments;
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php
index a5f6362..83557fe 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -46,10 +47,10 @@ protected function validateArguments(array $arguments) {
 
     // Fail when width or height are 0 or negative.
     if ($arguments['width'] <= 0) {
-      throw new \InvalidArgumentException(String::format("Invalid width (@value) specified for the image 'resize' operation", array('@value' => $arguments['width'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid width (@value) specified for the image 'resize' operation", array('@value' => $arguments['width'])));
     }
     if ($arguments['height'] <= 0) {
-      throw new \InvalidArgumentException(String::format("Invalid height (@value) specified for the image 'resize' operation", array('@value' => $arguments['height'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid height (@value) specified for the image 'resize' operation", array('@value' => $arguments['height'])));
     }
 
     return $arguments;
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php
index ee08c56..410ab13 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -73,10 +74,10 @@ protected function validateArguments(array $arguments) {
 
     // Fail when width or height are 0 or negative.
     if ($arguments['width'] <= 0) {
-      throw new \InvalidArgumentException(String::format("Invalid width (@value) specified for the image 'scale' operation", array('@value' => $arguments['width'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid width (@value) specified for the image 'scale' operation", array('@value' => $arguments['width'])));
     }
     if ($arguments['height'] <= 0) {
-      throw new \InvalidArgumentException(String::format("Invalid height (@value) specified for the image 'scale' operation", array('@value' => $arguments['height'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid height (@value) specified for the image 'scale' operation", array('@value' => $arguments['height'])));
     }
 
     return $arguments;
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php
index 832c5b4..743d6d5 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -54,10 +55,10 @@ protected function validateArguments(array $arguments) {
 
     // Fail when width or height are 0 or negative.
     if ($arguments['width'] <= 0) {
-      throw new \InvalidArgumentException(String::format("Invalid width (@value) specified for the image 'scale_and_crop' operation", array('@value' => $arguments['width'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid width (@value) specified for the image 'scale_and_crop' operation", array('@value' => $arguments['width'])));
     }
     if ($arguments['height'] <= 0) {
-      throw new \InvalidArgumentException(String::format("Invalid height (@value) specified for the image 'scale_and_crop' operation", array('@value' => $arguments['height'])));
+      throw new \InvalidArgumentException(SafeMarkup::format("Invalid height (@value) specified for the image 'scale_and_crop' operation", array('@value' => $arguments['height'])));
     }
 
     return $arguments;
diff --git a/core/modules/system/src/Tests/Ajax/FrameworkTest.php b/core/modules/system/src/Tests/Ajax/FrameworkTest.php
index 901db97..e509a6d 100644
--- a/core/modules/system/src/Tests/Ajax/FrameworkTest.php
+++ b/core/modules/system/src/Tests/Ajax/FrameworkTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Ajax;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Ajax\AddCssCommand;
 use Drupal\Core\Ajax\AlertCommand;
 use Drupal\Core\Ajax\AppendCommand;
@@ -114,9 +115,9 @@ public function testLazyLoad() {
 
     // Verify that the base page doesn't have the settings and files that are to
     // be lazy loaded as part of the next requests.
-    $this->assertTrue(!isset($original_settings[$expected['setting_name']]), format_string('Page originally lacks the %setting, as expected.', array('%setting' => $expected['setting_name'])));
-    $this->assertTrue(!in_array($expected['library_1'], $original_libraries), format_string('Page originally lacks the %library library, as expected.', array('%library' => $expected['library_1'])));
-    $this->assertTrue(!in_array($expected['library_2'], $original_libraries), format_string('Page originally lacks the %library library, as expected.', array('%library' => $expected['library_2'])));
+    $this->assertTrue(!isset($original_settings[$expected['setting_name']]), SafeMarkup::format('Page originally lacks the %setting, as expected.', array('%setting' => $expected['setting_name'])));
+    $this->assertTrue(!in_array($expected['library_1'], $original_libraries), SafeMarkup::format('Page originally lacks the %library library, as expected.', array('%library' => $expected['library_1'])));
+    $this->assertTrue(!in_array($expected['library_2'], $original_libraries), SafeMarkup::format('Page originally lacks the %library library, as expected.', array('%library' => $expected['library_2'])));
 
     // Calculate the expected CSS and JS.
     $assets = new AttachedAssets();
@@ -138,9 +139,9 @@ public function testLazyLoad() {
     $new_libraries = explode(',', $new_settings['ajaxPageState']['libraries']);
 
     // Verify the setting was not added when not expected.
-    $this->assertTrue(!isset($new_settings[$expected['setting_name']]), format_string('Page still lacks the %setting, as expected.', array('%setting' => $expected['setting_name'])));
-    $this->assertTrue(!in_array($expected['library_1'], $new_libraries), format_string('Page still lacks the %library library, as expected.', array('%library' => $expected['library_1'])));
-    $this->assertTrue(!in_array($expected['library_2'], $new_libraries), format_string('Page still lacks the %library library, as expected.', array('%library' => $expected['library_2'])));
+    $this->assertTrue(!isset($new_settings[$expected['setting_name']]), SafeMarkup::format('Page still lacks the %setting, as expected.', array('%setting' => $expected['setting_name'])));
+    $this->assertTrue(!in_array($expected['library_1'], $new_libraries), SafeMarkup::format('Page still lacks the %library library, as expected.', array('%library' => $expected['library_1'])));
+    $this->assertTrue(!in_array($expected['library_2'], $new_libraries), SafeMarkup::format('Page still lacks the %library library, as expected.', array('%library' => $expected['library_2'])));
     // Verify a settings command does not add CSS or scripts to drupalSettings
     // and no command inserts the corresponding tags on the page.
     $found_settings_command = FALSE;
@@ -153,8 +154,8 @@ public function testLazyLoad() {
         $found_markup_command = TRUE;
       }
     }
-    $this->assertFalse($found_settings_command, format_string('Page state still lacks the %library_1 and %library_2 libraries, as expected.', array('%library_1' => $expected['library_1'], '%library_2' => $expected['library_2'])));
-    $this->assertFalse($found_markup_command, format_string('Page still lacks the %library_1 and %library_2 libraries, as expected.', array('%library_1' => $expected['library_1'], '%library_2' => $expected['library_2'])));
+    $this->assertFalse($found_settings_command, SafeMarkup::format('Page state still lacks the %library_1 and %library_2 libraries, as expected.', array('%library_1' => $expected['library_1'], '%library_2' => $expected['library_2'])));
+    $this->assertFalse($found_markup_command, SafeMarkup::format('Page still lacks the %library_1 and %library_2 libraries, as expected.', array('%library_1' => $expected['library_1'], '%library_2' => $expected['library_2'])));
 
     // Submit the AJAX request and trigger adding files.
     $commands = $this->drupalPostAjaxForm(NULL, array('add_files' => TRUE), array('op' => t('Submit')));
@@ -163,14 +164,14 @@ public function testLazyLoad() {
 
     // Verify the expected setting was added, both to drupalSettings, and as
     // the first AJAX command.
-    $this->assertIdentical($new_settings[$expected['setting_name']], $expected['setting_value'], format_string('Page now has the %setting.', array('%setting' => $expected['setting_name'])));
+    $this->assertIdentical($new_settings[$expected['setting_name']], $expected['setting_value'], SafeMarkup::format('Page now has the %setting.', array('%setting' => $expected['setting_name'])));
     $expected_command = new SettingsCommand(array($expected['setting_name'] => $expected['setting_value']), TRUE);
-    $this->assertCommand(array_slice($commands, 0, 1), $expected_command->render(), format_string('The settings command was first.'));
+    $this->assertCommand(array_slice($commands, 0, 1), $expected_command->render(), SafeMarkup::format('The settings command was first.'));
 
     // Verify the expected CSS file was added, both to drupalSettings, and as
     // the second AJAX command for inclusion into the HTML.
-    $this->assertTrue(in_array($expected['library_1'], $new_libraries), format_string('Page state now has the %library library.', array('%library' => $expected['library_1'])));
-    $this->assertCommand(array_slice($commands, 1, 1), array('data' => $expected_css_html), format_string('Page now has the %library library.', array('%library' => $expected['library_1'])));
+    $this->assertTrue(in_array($expected['library_1'], $new_libraries), SafeMarkup::format('Page state now has the %library library.', array('%library' => $expected['library_1'])));
+    $this->assertCommand(array_slice($commands, 1, 1), array('data' => $expected_css_html), SafeMarkup::format('Page now has the %library library.', array('%library' => $expected['library_1'])));
 
     // Verify the expected JS file was added, both to drupalSettings, and as
     // the third AJAX command for inclusion into the HTML. By testing for an
@@ -178,8 +179,8 @@ public function testLazyLoad() {
     // unexpected JavaScript code, such as a jQuery.extend() that would
     // potentially clobber rather than properly merge settings, didn't
     // accidentally get added.
-    $this->assertTrue(in_array($expected['library_2'], $new_libraries), format_string('Page state now has the %library library.', array('%library' => $expected['library_2'])));
-    $this->assertCommand(array_slice($commands, 2, 1), array('data' => $expected_js_html), format_string('Page now has the %library library.', array('%library' => $expected['library_2'])));
+    $this->assertTrue(in_array($expected['library_2'], $new_libraries), SafeMarkup::format('Page state now has the %library library.', array('%library' => $expected['library_2'])));
+    $this->assertCommand(array_slice($commands, 2, 1), array('data' => $expected_js_html), SafeMarkup::format('Page now has the %library library.', array('%library' => $expected['library_2'])));
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php b/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php
index 0361eb7..557f60f 100644
--- a/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php
+++ b/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php
@@ -5,6 +5,7 @@
 
 namespace Drupal\system\Tests\Block;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Render\Element;
 use Drupal\simpletest\KernelTestBase;
 use Drupal\system\Tests\Routing\MockRouteProvider;
@@ -230,7 +231,7 @@ public function testConfigLevelDepth() {
     foreach ($blocks as $id => $block) {
       $block_build = $block->build();
       $items = isset($block_build['#items']) ? $block_build['#items'] : [];
-      $this->assertIdentical($no_active_trail_expectations[$id], $this->convertBuiltMenuToIdTree($items), format_string('Menu block %id with no active trail renders the expected tree.', ['%id' => $id]));
+      $this->assertIdentical($no_active_trail_expectations[$id], $this->convertBuiltMenuToIdTree($items), SafeMarkup::format('Menu block %id with no active trail renders the expected tree.', ['%id' => $id]));
     }
 
     // Scenario 2: test all block instances when there's an active trail.
@@ -278,7 +279,7 @@ public function testConfigLevelDepth() {
     foreach ($blocks as $id => $block) {
       $block_build = $block->build();
       $items = isset($block_build['#items']) ? $block_build['#items'] : [];
-      $this->assertIdentical($active_trail_expectations[$id], $this->convertBuiltMenuToIdTree($items), format_string('Menu block %id with an active trail renders the expected tree.', ['%id' => $id]));
+      $this->assertIdentical($active_trail_expectations[$id], $this->convertBuiltMenuToIdTree($items), SafeMarkup::format('Menu block %id with an active trail renders the expected tree.', ['%id' => $id]));
     }
   }
 
diff --git a/core/modules/system/src/Tests/Cache/ClearTest.php b/core/modules/system/src/Tests/Cache/ClearTest.php
index 1a152ed..b9f3d51 100644
--- a/core/modules/system/src/Tests/Cache/ClearTest.php
+++ b/core/modules/system/src/Tests/Cache/ClearTest.php
@@ -12,6 +12,7 @@
  *
  * @group Cache
  */
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Cache\Cache;
 
 class ClearTest extends CacheTestBase {
@@ -40,7 +41,7 @@ function testFlushAllCaches() {
 
     foreach ($bins as $bin => $cache_backend) {
       $cid = 'test_cid_clear' . $bin;
-      $this->assertFalse($this->checkCacheExists($cid, $this->default_value, $bin), format_string('All cache entries removed from @bin.', array('@bin' => $bin)));
+      $this->assertFalse($this->checkCacheExists($cid, $this->default_value, $bin), SafeMarkup::format('All cache entries removed from @bin.', array('@bin' => $bin)));
     }
   }
 }
diff --git a/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php b/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php
index 3e3b1bc..96673a1 100644
--- a/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php
+++ b/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Cache;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Url;
 use Drupal\simpletest\WebTestBase;
 use Drupal\Component\Utility\String;
@@ -50,7 +51,7 @@ protected function setUp() {
    */
   protected function verifyPageCache(Url $url, $hit_or_miss, $tags = FALSE) {
     $this->drupalGet($url);
-    $message = String::format('Page cache @hit_or_miss for %path.', array('@hit_or_miss' => $hit_or_miss, '%path' => $url->toString()));
+    $message = SafeMarkup::format('Page cache @hit_or_miss for %path.', array('@hit_or_miss' => $hit_or_miss, '%path' => $url->toString()));
     $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), $hit_or_miss, $message);
 
     if ($hit_or_miss === 'HIT' && is_array($tags)) {
diff --git a/core/modules/system/src/Tests/Common/AddFeedTest.php b/core/modules/system/src/Tests/Common/AddFeedTest.php
index 5da8ffb..5442964 100644
--- a/core/modules/system/src/Tests/Common/AddFeedTest.php
+++ b/core/modules/system/src/Tests/Common/AddFeedTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Common;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Url;
 use Drupal\simpletest\WebTestBase;
 
@@ -65,7 +66,7 @@ function testBasicFeedAddNoTitle() {
 
     $this->setRawContent(drupal_get_html_head());
     foreach ($urls as $description => $feed_info) {
-      $this->assertPattern($this->urlToRSSLinkPattern($feed_info['url'], $feed_info['title']), format_string('Found correct feed header for %description', array('%description' => $description)));
+      $this->assertPattern($this->urlToRSSLinkPattern($feed_info['url'], $feed_info['title']), SafeMarkup::format('Found correct feed header for %description', array('%description' => $description)));
     }
   }
 
diff --git a/core/modules/system/src/Tests/Common/RenderWebTest.php b/core/modules/system/src/Tests/Common/RenderWebTest.php
index 4bdb996..45a5449 100644
--- a/core/modules/system/src/Tests/Common/RenderWebTest.php
+++ b/core/modules/system/src/Tests/Common/RenderWebTest.php
@@ -155,7 +155,7 @@ protected function assertRenderedElement(array $element, $xpath, array $xpath_ar
     // @see \Drupal\simpletest\WebTestBase::xpath()
     $xpath = $this->buildXPathQuery($xpath, $xpath_args);
     $element += array('#value' => NULL);
-    $this->assertFieldByXPath($xpath, $element['#value'], format_string('#type @type was properly rendered.', array(
+    $this->assertFieldByXPath($xpath, $element['#value'], SafeMarkup::format('#type @type was properly rendered.', array(
       '@type' => var_export($element['#type'], TRUE),
     )));
   }
diff --git a/core/modules/system/src/Tests/Common/SimpleTestErrorCollectorTest.php b/core/modules/system/src/Tests/Common/SimpleTestErrorCollectorTest.php
index ae419ff..5eee4f8 100644
--- a/core/modules/system/src/Tests/Common/SimpleTestErrorCollectorTest.php
+++ b/core/modules/system/src/Tests/Common/SimpleTestErrorCollectorTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Common;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -88,11 +89,11 @@ protected function error($message = '', $group = 'Other', array $caller = NULL)
    * Asserts that a collected error matches what we are expecting.
    */
   function assertError($error, $group, $function, $file, $message = NULL) {
-    $this->assertEqual($error['group'], $group, format_string("Group was %group", array('%group' => $group)));
-    $this->assertEqual($error['caller']['function'], $function, format_string("Function was %function", array('%function' => $function)));
-    $this->assertEqual(drupal_basename($error['caller']['file']), $file, format_string("File was %file", array('%file' => $file)));
+    $this->assertEqual($error['group'], $group, SafeMarkup::format("Group was %group", array('%group' => $group)));
+    $this->assertEqual($error['caller']['function'], $function, SafeMarkup::format("Function was %function", array('%function' => $function)));
+    $this->assertEqual(drupal_basename($error['caller']['file']), $file, SafeMarkup::format("File was %file", array('%file' => $file)));
     if (isset($message)) {
-      $this->assertEqual($error['message'], $message, format_string("Message was %message", array('%message' => $message)));
+      $this->assertEqual($error['message'], $message, SafeMarkup::format("Message was %message", array('%message' => $message)));
     }
   }
 }
diff --git a/core/modules/system/src/Tests/Common/SystemListingTest.php b/core/modules/system/src/Tests/Common/SystemListingTest.php
index 861a1df..07c36bd 100644
--- a/core/modules/system/src/Tests/Common/SystemListingTest.php
+++ b/core/modules/system/src/Tests/Common/SystemListingTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Common;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Extension\ExtensionDiscovery;
 use Drupal\simpletest\KernelTestBase;
 
@@ -37,7 +38,7 @@ function testDirectoryPrecedence() {
     foreach ($expected_directories as $module => $directories) {
       foreach ($directories as $directory) {
         $filename = "$directory/$module/$module.info.yml";
-        $this->assertTrue(file_exists(\Drupal::root() . '/' . $filename), format_string('@filename exists.', array('@filename' => $filename)));
+        $this->assertTrue(file_exists(DRUPAL_ROOT . '/' . $filename), SafeMarkup::format('@filename exists.', array('@filename' => $filename)));
       }
     }
 
@@ -49,7 +50,7 @@ function testDirectoryPrecedence() {
     foreach ($expected_directories as $module => $directories) {
       $expected_directory = array_shift($directories);
       $expected_uri = "$expected_directory/$module/$module.info.yml";
-      $this->assertEqual($files[$module]->getPathname(), $expected_uri, format_string('Module @actual was found at @expected.', array(
+      $this->assertEqual($files[$module]->getPathname(), $expected_uri, SafeMarkup::format('Module @actual was found at @expected.', array(
         '@actual' => $files[$module]->getPathname(),
         '@expected' => $expected_uri,
       )));
diff --git a/core/modules/system/src/Tests/Common/UrlTest.php b/core/modules/system/src/Tests/Common/UrlTest.php
index 6beeb31..5b9e393 100644
--- a/core/modules/system/src/Tests/Common/UrlTest.php
+++ b/core/modules/system/src/Tests/Common/UrlTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Common;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\UrlHelper;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Url;
@@ -33,12 +34,12 @@ function testLinkXSS() {
     $path = "<SCRIPT>alert('XSS')</SCRIPT>";
     $link = \Drupal::l($text, Url::fromUserInput('/' . $path));
     $sanitized_path = check_url(Url::fromUri('base:' . $path)->toString());
-    $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, format_string('XSS attack @path was filtered by _l().', array('@path' => $path)));
+    $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, SafeMarkup::format('XSS attack @path was filtered by _l().', array('@path' => $path)));
 
     // Test \Drupal\Core\Url.
     $link = Url::fromUri('base:' . $path)->toString();
     $sanitized_path = check_url(Url::fromUri('base:' . $path)->toString());
-    $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, format_string('XSS attack @path was filtered by #theme', ['@path' => $path]));
+    $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, SafeMarkup::format('XSS attack @path was filtered by #theme', ['@path' => $path]));
   }
 
   /**
@@ -63,10 +64,10 @@ function testLinkAttributes() {
     $hreflang_override_link['#options']['attributes']['hreflang'] = 'foo';
 
     $rendered = drupal_render($hreflang_link);
-    $this->assertTrue($this->hasAttribute('hreflang', $rendered, $langcode), format_string('hreflang attribute with value @langcode is present on a rendered link when langcode is provided in the render array.', array('@langcode' => $langcode)));
+    $this->assertTrue($this->hasAttribute('hreflang', $rendered, $langcode), SafeMarkup::format('hreflang attribute with value @langcode is present on a rendered link when langcode is provided in the render array.', array('@langcode' => $langcode)));
 
     $rendered = drupal_render($hreflang_override_link);
-    $this->assertTrue($this->hasAttribute('hreflang', $rendered, 'foo'), format_string('hreflang attribute with value @hreflang is present on a rendered link when @hreflang is provided in the render array.', array('@hreflang' => 'foo')));
+    $this->assertTrue($this->hasAttribute('hreflang', $rendered, 'foo'), SafeMarkup::format('hreflang attribute with value @hreflang is present on a rendered link when @hreflang is provided in the render array.', array('@hreflang' => 'foo')));
 
     // Test the active class in links produced by _l() and #type 'link'.
     $options_no_query = array();
@@ -107,7 +108,7 @@ function testLinkAttributes() {
     // Test _l().
     $class_l = $this->randomMachineName();
     $link_l = \Drupal::l($this->randomMachineName(), new Url('<current>', [], ['attributes' => ['class' => [$class_l]]]));
-    $this->assertTrue($this->hasAttribute('class', $link_l, $class_l), format_string('Custom class @class is present on link when requested by l()', array('@class' => $class_l)));
+    $this->assertTrue($this->hasAttribute('class', $link_l, $class_l), SafeMarkup::format('Custom class @class is present on link when requested by l()', array('@class' => $class_l)));
 
     // Test #type.
     $class_theme = $this->randomMachineName();
@@ -122,7 +123,7 @@ function testLinkAttributes() {
       ),
     );
     $link_theme = drupal_render($type_link);
-    $this->assertTrue($this->hasAttribute('class', $link_theme, $class_theme), format_string('Custom class @class is present on link when requested by #type', array('@class' => $class_theme)));
+    $this->assertTrue($this->hasAttribute('class', $link_theme, $class_theme), SafeMarkup::format('Custom class @class is present on link when requested by #type', array('@class' => $class_theme)));
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php b/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php
index 164b1e9..6027932 100644
--- a/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php
+++ b/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Condition;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\simpletest\KernelTestBase;
 
@@ -44,8 +45,8 @@ public function testCurrentTheme() {
     $condition_negated = $manager->createInstance('current_theme');
     $condition_negated->setConfiguration(array('theme' => 'test_theme', 'negate' => TRUE));
 
-    $this->assertEqual($condition->summary(), String::format('The current theme is @theme', array('@theme' => 'test_theme')));
-    $this->assertEqual($condition_negated->summary(), String::format('The current theme is not @theme', array('@theme' => 'test_theme')));
+    $this->assertEqual($condition->summary(), SafeMarkup::format('The current theme is @theme', array('@theme' => 'test_theme')));
+    $this->assertEqual($condition_negated->summary(), SafeMarkup::format('The current theme is not @theme', array('@theme' => 'test_theme')));
 
     // The expected theme has not been set up yet.
     $this->assertFalse($condition->execute());
diff --git a/core/modules/system/src/Tests/Database/ConnectionUnitTest.php b/core/modules/system/src/Tests/Database/ConnectionUnitTest.php
index 74d0de7..8e121fc 100644
--- a/core/modules/system/src/Tests/Database/ConnectionUnitTest.php
+++ b/core/modules/system/src/Tests/Database/ConnectionUnitTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\system\Tests\Database;
 
 use Doctrine\Common\Reflection\StaticReflectionProperty;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Database\Database;
 use Drupal\Core\Site\Settings;
 use Drupal\simpletest\KernelTestBase;
@@ -82,7 +83,7 @@ protected function getConnectionID() {
    */
   protected function assertConnection($id) {
     $list = $this->monitor->query('SHOW PROCESSLIST')->fetchAllKeyed(0, 0);
-    return $this->assertTrue(isset($list[$id]), format_string('Connection ID @id found.', array('@id' => $id)));
+    return $this->assertTrue(isset($list[$id]), SafeMarkup::format('Connection ID @id found.', array('@id' => $id)));
   }
 
   /**
@@ -93,7 +94,7 @@ protected function assertConnection($id) {
    */
   protected function assertNoConnection($id) {
     $list = $this->monitor->query('SHOW PROCESSLIST')->fetchAllKeyed(0, 0);
-    return $this->assertFalse(isset($list[$id]), format_string('Connection ID @id not found.', array('@id' => $id)));
+    return $this->assertFalse(isset($list[$id]), SafeMarkup::format('Connection ID @id not found.', array('@id' => $id)));
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Database/InsertLobTest.php b/core/modules/system/src/Tests/Database/InsertLobTest.php
index 2fcf182..21d6d91 100644
--- a/core/modules/system/src/Tests/Database/InsertLobTest.php
+++ b/core/modules/system/src/Tests/Database/InsertLobTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\system\Tests\Database;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests the Insert query builder with LOB fields.
@@ -24,7 +25,7 @@ function testInsertOneBlob() {
       ->fields(array('blob1' => $data))
       ->execute();
     $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(':id' => $id))->fetchAssoc();
-    $this->assertTrue($r['blob1'] === $data, format_string('Can insert a blob: id @id, @data.', array('@id' => $id, '@data' => serialize($r))));
+    $this->assertTrue($r['blob1'] === $data, SafeMarkup::format('Can insert a blob: id @id, @data.', array('@id' => $id, '@data' => serialize($r))));
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Database/SchemaTest.php b/core/modules/system/src/Tests/Database/SchemaTest.php
index 6b96e3d..9e20179 100644
--- a/core/modules/system/src/Tests/Database/SchemaTest.php
+++ b/core/modules/system/src/Tests/Database/SchemaTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Database;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Database\Database;
 use Drupal\Core\Database\SchemaObjectDoesNotExistException;
 use Drupal\Core\Database\SchemaObjectExistsException;
@@ -287,8 +288,8 @@ function testUnsignedColumns() {
 
     // Finally, check each column and try to insert invalid values into them.
     foreach ($table_spec['fields'] as $column_name => $column_spec) {
-      $this->assertTrue(db_field_exists($table_name, $column_name), format_string('Unsigned @type column was created.', array('@type' => $column_spec['type'])));
-      $this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), format_string('Unsigned @type column rejected a negative value.', array('@type' => $column_spec['type'])));
+      $this->assertTrue(db_field_exists($table_name, $column_name), SafeMarkup::format('Unsigned @type column was created.', array('@type' => $column_spec['type'])));
+      $this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), SafeMarkup::format('Unsigned @type column rejected a negative value.', array('@type' => $column_spec['type'])));
     }
   }
 
@@ -410,7 +411,7 @@ protected function assertFieldAdditionRemoval($field_spec) {
       'primary key' => array('serial_column'),
     );
     db_create_table($table_name, $table_spec);
-    $this->pass(format_string('Table %table created.', array('%table' => $table_name)));
+    $this->pass(SafeMarkup::format('Table %table created.', array('%table' => $table_name)));
 
     // Check the characteristics of the field.
     $this->assertFieldCharacteristics($table_name, 'test_field', $field_spec);
@@ -427,7 +428,7 @@ protected function assertFieldAdditionRemoval($field_spec) {
       'primary key' => array('serial_column'),
     );
     db_create_table($table_name, $table_spec);
-    $this->pass(format_string('Table %table created.', array('%table' => $table_name)));
+    $this->pass(SafeMarkup::format('Table %table created.', array('%table' => $table_name)));
 
     // Insert some rows to the table to test the handling of initial values.
     for ($i = 0; $i < 3; $i++) {
@@ -437,7 +438,7 @@ protected function assertFieldAdditionRemoval($field_spec) {
     }
 
     db_add_field($table_name, 'test_field', $field_spec);
-    $this->pass(format_string('Column %column created.', array('%column' => 'test_field')));
+    $this->pass(SafeMarkup::format('Column %column created.', array('%column' => 'test_field')));
 
     // Check the characteristics of the field.
     $this->assertFieldCharacteristics($table_name, 'test_field', $field_spec);
@@ -520,7 +521,7 @@ protected function assertFieldChange($old_spec, $new_spec) {
       'primary key' => array('serial_column'),
     );
     db_create_table($table_name, $table_spec);
-    $this->pass(format_string('Table %table created.', array('%table' => $table_name)));
+    $this->pass(SafeMarkup::format('Table %table created.', array('%table' => $table_name)));
 
     // Check the characteristics of the field.
     $this->assertFieldCharacteristics($table_name, 'test_field', $old_spec);
diff --git a/core/modules/system/src/Tests/Database/SelectComplexTest.php b/core/modules/system/src/Tests/Database/SelectComplexTest.php
index 2b6b3db..4fefb3d 100644
--- a/core/modules/system/src/Tests/Database/SelectComplexTest.php
+++ b/core/modules/system/src/Tests/Database/SelectComplexTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Database;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Database\Database;
 use Drupal\Core\Database\RowCountException;
 
@@ -103,7 +104,7 @@ function testGroupBy() {
     );
 
     foreach ($correct_results as $task => $count) {
-      $this->assertEqual($records[$task], $count, format_string("Correct number of '@task' records found.", array('@task' => $task)));
+      $this->assertEqual($records[$task], $count, SafeMarkup::format("Correct number of '@task' records found.", array('@task' => $task)));
     }
 
     $this->assertEqual($num_records, 6, 'Returned the correct number of total rows.');
@@ -137,7 +138,7 @@ function testGroupByAndHaving() {
     );
 
     foreach ($correct_results as $task => $count) {
-      $this->assertEqual($records[$task], $count, format_string("Correct number of '@task' records found.", array('@task' => $task)));
+      $this->assertEqual($records[$task], $count, SafeMarkup::format("Correct number of '@task' records found.", array('@task' => $task)));
     }
 
     $this->assertEqual($num_records, 1, 'Returned the correct number of total rows.');
diff --git a/core/modules/system/src/Tests/Database/SelectPagerDefaultTest.php b/core/modules/system/src/Tests/Database/SelectPagerDefaultTest.php
index 5a3455c..5895d75 100644
--- a/core/modules/system/src/Tests/Database/SelectPagerDefaultTest.php
+++ b/core/modules/system/src/Tests/Database/SelectPagerDefaultTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\system\Tests\Database;
+use Drupal\Component\Utility\SafeMarkup;
 use Symfony\Component\HttpFoundation\Request;
 
 /**
@@ -45,7 +46,7 @@ function testEvenPagerQuery() {
         $correct_number = $count - ($limit * $page);
       }
 
-      $this->assertEqual(count($data->names), $correct_number, format_string('Correct number of records returned by pager: @number', array('@number' => $correct_number)));
+      $this->assertEqual(count($data->names), $correct_number, SafeMarkup::format('Correct number of records returned by pager: @number', array('@number' => $correct_number)));
     }
   }
 
@@ -79,7 +80,7 @@ function testOddPagerQuery() {
         $correct_number = $count - ($limit * $page);
       }
 
-      $this->assertEqual(count($data->names), $correct_number, format_string('Correct number of records returned by pager: @number', array('@number' => $correct_number)));
+      $this->assertEqual(count($data->names), $correct_number, SafeMarkup::format('Correct number of records returned by pager: @number', array('@number' => $correct_number)));
     }
   }
 
diff --git a/core/modules/system/src/Tests/Database/SelectTableSortDefaultTest.php b/core/modules/system/src/Tests/Database/SelectTableSortDefaultTest.php
index 4456701..bfd7d70 100644
--- a/core/modules/system/src/Tests/Database/SelectTableSortDefaultTest.php
+++ b/core/modules/system/src/Tests/Database/SelectTableSortDefaultTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\system\Tests\Database;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests the tablesort query extender.
@@ -65,8 +66,8 @@ function testTableSortQueryFirst() {
       $first = array_shift($data->tasks);
       $last = array_pop($data->tasks);
 
-      $this->assertEqual($first->task, $sort['first'], format_string('Items appear in the correct order sorting by @field @sort.', array('@field' => $sort['field'], '@sort' => $sort['sort'])));
-      $this->assertEqual($last->task, $sort['last'], format_string('Items appear in the correct order sorting by @field @sort.', array('@field' => $sort['field'], '@sort' => $sort['sort'])));
+      $this->assertEqual($first->task, $sort['first'], SafeMarkup::format('Items appear in the correct order sorting by @field @sort.', array('@field' => $sort['field'], '@sort' => $sort['sort'])));
+      $this->assertEqual($last->task, $sort['last'], SafeMarkup::format('Items appear in the correct order sorting by @field @sort.', array('@field' => $sort['field'], '@sort' => $sort['sort'])));
     }
   }
 
diff --git a/core/modules/system/src/Tests/Database/TransactionTest.php b/core/modules/system/src/Tests/Database/TransactionTest.php
index 00ec458..d4ecbdb 100644
--- a/core/modules/system/src/Tests/Database/TransactionTest.php
+++ b/core/modules/system/src/Tests/Database/TransactionTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Database;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Database\Database;
 use Drupal\Core\Database\TransactionOutOfOrderException;
 use Drupal\Core\Database\TransactionNoActiveException;
@@ -359,7 +360,7 @@ protected function cleanUp() {
    */
   function assertRowPresent($name, $message = NULL) {
     if (!isset($message)) {
-      $message = format_string('Row %name is present.', array('%name' => $name));
+      $message = SafeMarkup::format('Row %name is present.', array('%name' => $name));
     }
     $present = (boolean) db_query('SELECT 1 FROM {test} WHERE name = :name', array(':name' => $name))->fetchField();
     return $this->assertTrue($present, $message);
@@ -375,7 +376,7 @@ function assertRowPresent($name, $message = NULL) {
    */
   function assertRowAbsent($name, $message = NULL) {
     if (!isset($message)) {
-      $message = format_string('Row %name is absent.', array('%name' => $name));
+      $message = SafeMarkup::format('Row %name is absent.', array('%name' => $name));
     }
     $present = (boolean) db_query('SELECT 1 FROM {test} WHERE name = :name', array(':name' => $name))->fetchField();
     return $this->assertFalse($present, $message);
diff --git a/core/modules/system/src/Tests/Database/UpdateLobTest.php b/core/modules/system/src/Tests/Database/UpdateLobTest.php
index 7b26fdf..782a190 100644
--- a/core/modules/system/src/Tests/Database/UpdateLobTest.php
+++ b/core/modules/system/src/Tests/Database/UpdateLobTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\system\Tests\Database;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests the Update query builder with LOB fields.
@@ -31,7 +32,7 @@ function testUpdateOneBlob() {
       ->execute();
 
     $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(':id' => $id))->fetchAssoc();
-    $this->assertTrue($r['blob1'] === $data, format_string('Can update a blob: id @id, @data.', array('@id' => $id, '@data' => serialize($r))));
+    $this->assertTrue($r['blob1'] === $data, SafeMarkup::format('Can update a blob: id @id, @data.', array('@id' => $id, '@data' => serialize($r))));
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php b/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php
index d11a945..166de13 100644
--- a/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Access\AccessibleInterface;
 use Drupal\Core\Entity\EntityAccessControlHandler;
@@ -29,7 +30,7 @@ protected function setUp() {
    */
   function assertEntityAccess($ops, AccessibleInterface $object, AccountInterface $account = NULL) {
     foreach ($ops as $op => $result) {
-      $message = format_string("Entity access returns @result with operation '@op'.", array(
+      $message = SafeMarkup::format("Entity access returns @result with operation '@op'.", array(
         '@result' => !isset($result) ? 'null' : ($result ? 'true' : 'false'),
         '@op' => $op,
       ));
diff --git a/core/modules/system/src/Tests/Entity/EntityApiTest.php b/core/modules/system/src/Tests/Entity/EntityApiTest.php
index decbcd0..2794ac4 100644
--- a/core/modules/system/src/Tests/Entity/EntityApiTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityApiTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\EntityStorageException;
 use Drupal\user\UserInterface;
 
@@ -59,32 +60,32 @@ protected function assertCRUD($entity_type, UserInterface $user1) {
     $entity->save();
 
     $entities = array_values(entity_load_multiple_by_properties($entity_type, array('name' => 'test')));
-    $this->assertEqual($entities[0]->name->value, 'test', format_string('%entity_type: Created and loaded entity', array('%entity_type' => $entity_type)));
-    $this->assertEqual($entities[1]->name->value, 'test', format_string('%entity_type: Created and loaded entity', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entities[0]->name->value, 'test', SafeMarkup::format('%entity_type: Created and loaded entity', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entities[1]->name->value, 'test', SafeMarkup::format('%entity_type: Created and loaded entity', array('%entity_type' => $entity_type)));
 
     // Test loading a single entity.
     $loaded_entity = entity_load($entity_type, $entity->id());
-    $this->assertEqual($loaded_entity->id(), $entity->id(), format_string('%entity_type: Loaded a single entity by id.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($loaded_entity->id(), $entity->id(), SafeMarkup::format('%entity_type: Loaded a single entity by id.', array('%entity_type' => $entity_type)));
 
     // Test deleting an entity.
     $entities = array_values(entity_load_multiple_by_properties($entity_type, array('name' => 'test2')));
     $entities[0]->delete();
     $entities = array_values(entity_load_multiple_by_properties($entity_type, array('name' => 'test2')));
-    $this->assertEqual($entities, array(), format_string('%entity_type: Entity deleted.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entities, array(), SafeMarkup::format('%entity_type: Entity deleted.', array('%entity_type' => $entity_type)));
 
     // Test updating an entity.
     $entities = array_values(entity_load_multiple_by_properties($entity_type, array('name' => 'test')));
     $entities[0]->name->value = 'test3';
     $entities[0]->save();
     $entity = entity_load($entity_type, $entities[0]->id());
-    $this->assertEqual($entity->name->value, 'test3', format_string('%entity_type: Entity updated.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name->value, 'test3', SafeMarkup::format('%entity_type: Entity updated.', array('%entity_type' => $entity_type)));
 
     // Try deleting multiple test entities by deleting all.
     $ids = array_keys(entity_load_multiple($entity_type));
     entity_delete_multiple($entity_type, $ids);
 
     $all = entity_load_multiple($entity_type);
-    $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', array('%entity_type' => $entity_type)));
+    $this->assertTrue(empty($all), SafeMarkup::format('%entity_type: Deleted all entities.', array('%entity_type' => $entity_type)));
 
     // Verify that all data got deleted.
     $definition = \Drupal::entityManager()->getDefinition($entity_type);
diff --git a/core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php b/core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php
index 32861c7..fad3192 100644
--- a/core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Uuid\Uuid;
 use Drupal\Component\Utility\String;
 
@@ -50,8 +51,8 @@ protected function assertDefaultValues($entity_type_id) {
     $entity = entity_create($entity_type_id);
     $definition = $this->entityManager->getDefinition($entity_type_id);
     $langcode_key = $definition->getKey('langcode');
-    $this->assertEqual($entity->{$langcode_key}->value, 'en', String::format('%entity_type: Default language', array('%entity_type' => $entity_type_id)));
-    $this->assertTrue(Uuid::isValid($entity->uuid->value), String::format('%entity_type: Default UUID', array('%entity_type' => $entity_type_id)));
+    $this->assertEqual($entity->{$langcode_key}->value, 'en', SafeMarkup::format('%entity_type: Default language', array('%entity_type' => $entity_type_id)));
+    $this->assertTrue(Uuid::isValid($entity->uuid->value), SafeMarkup::format('%entity_type: Default UUID', array('%entity_type' => $entity_type_id)));
     $this->assertEqual($entity->name->getValue(), array(), 'Field has one empty value by default.');
   }
 
diff --git a/core/modules/system/src/Tests/Entity/EntityFieldTest.php b/core/modules/system/src/Tests/Entity/EntityFieldTest.php
index 8be7a1d..4351325 100644
--- a/core/modules/system/src/Tests/Entity/EntityFieldTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityFieldTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Field\BaseFieldDefinition;
 use Drupal\Core\Field\FieldDefinitionInterface;
@@ -108,66 +109,66 @@ protected function doTestReadWrite($entity_type) {
     $langcode = 'en';
 
     // Access the name field.
-    $this->assertTrue($entity->name instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', array('%entity_type' => $entity_type)));
-    $this->assertTrue($entity->name[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', array('%entity_type' => $entity_type)));
+    $this->assertTrue($entity->name instanceof FieldItemListInterface, SafeMarkup::format('%entity_type: Field implements interface', array('%entity_type' => $entity_type)));
+    $this->assertTrue($entity->name[0] instanceof FieldItemInterface, SafeMarkup::format('%entity_type: Field item implements interface', array('%entity_type' => $entity_type)));
 
-    $this->assertEqual($this->entity_name, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($this->entity_name, $entity->name[0]->value, format_string('%entity_type: Name value can be read through list access.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $this->entity_name)), format_string('%entity_type: Plain field value returned.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_name, $entity->name->value, SafeMarkup::format('%entity_type: Name value can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_name, $entity->name[0]->value, SafeMarkup::format('%entity_type: Name value can be read through list access.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $this->entity_name)), SafeMarkup::format('%entity_type: Plain field value returned.', array('%entity_type' => $entity_type)));
 
     // Change the name.
     $new_name = $this->randomMachineName();
     $entity->name->value = $new_name;
-    $this->assertEqual($new_name, $entity->name->value, format_string('%entity_type: Name can be updated and read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $new_name)), format_string('%entity_type: Plain field value reflects the update.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_name, $entity->name->value, SafeMarkup::format('%entity_type: Name can be updated and read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $new_name)), SafeMarkup::format('%entity_type: Plain field value reflects the update.', array('%entity_type' => $entity_type)));
 
     $new_name = $this->randomMachineName();
     $entity->name[0]->value = $new_name;
-    $this->assertEqual($new_name, $entity->name->value, format_string('%entity_type: Name can be updated and read through list access.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_name, $entity->name->value, SafeMarkup::format('%entity_type: Name can be updated and read through list access.', array('%entity_type' => $entity_type)));
 
     // Access the user field.
-    $this->assertTrue($entity->user_id instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', array('%entity_type' => $entity_type)));
-    $this->assertTrue($entity->user_id[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', array('%entity_type' => $entity_type)));
+    $this->assertTrue($entity->user_id instanceof FieldItemListInterface, SafeMarkup::format('%entity_type: Field implements interface', array('%entity_type' => $entity_type)));
+    $this->assertTrue($entity->user_id[0] instanceof FieldItemInterface, SafeMarkup::format('%entity_type: Field item implements interface', array('%entity_type' => $entity_type)));
 
-    $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($this->entity_user->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, SafeMarkup::format('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_user->getUsername(), $entity->user_id->entity->name->value, SafeMarkup::format('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
 
     // Change the assigned user by entity.
     $new_user1 = $this->createUser();
     $entity->user_id->entity = $new_user1;
-    $this->assertEqual($new_user1->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($new_user1->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated username value can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_user1->id(), $entity->user_id->target_id, SafeMarkup::format('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_user1->getUsername(), $entity->user_id->entity->name->value, SafeMarkup::format('%entity_type: Updated username value can be read.', array('%entity_type' => $entity_type)));
 
     // Change the assigned user by id.
     $new_user2 = $this->createUser();
     $entity->user_id->target_id = $new_user2->id();
-    $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated username value can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_user2->id(), $entity->user_id->target_id, SafeMarkup::format('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, SafeMarkup::format('%entity_type: Updated username value can be read.', array('%entity_type' => $entity_type)));
 
     // Try unsetting a field property.
     $entity->name->value = NULL;
     $entity->user_id->target_id = NULL;
-    $this->assertNull($entity->name->value, format_string('%entity_type: Name field is not set.', array('%entity_type' => $entity_type)));
-    $this->assertNull($entity->user_id->target_id, format_string('%entity_type: User ID field is not set.', array('%entity_type' => $entity_type)));
-    $this->assertNull($entity->user_id->entity, format_string('%entity_type: User entity field is not set.', array('%entity_type' => $entity_type)));
+    $this->assertNull($entity->name->value, SafeMarkup::format('%entity_type: Name field is not set.', array('%entity_type' => $entity_type)));
+    $this->assertNull($entity->user_id->target_id, SafeMarkup::format('%entity_type: User ID field is not set.', array('%entity_type' => $entity_type)));
+    $this->assertNull($entity->user_id->entity, SafeMarkup::format('%entity_type: User entity field is not set.', array('%entity_type' => $entity_type)));
 
     // Test setting the values via the typed data API works as well.
     // Change the assigned user by entity.
     $entity->user_id->first()->get('entity')->setValue($new_user2);
-    $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_user2->id(), $entity->user_id->target_id, SafeMarkup::format('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, SafeMarkup::format('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type)));
 
     // Change the assigned user by id.
     $entity->user_id->first()->get('target_id')->setValue($new_user2->id());
-    $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_user2->id(), $entity->user_id->target_id, SafeMarkup::format('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, SafeMarkup::format('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type)));
 
     // Try unsetting a field.
     $entity->name->first()->get('value')->setValue(NULL);
     $entity->user_id->first()->get('target_id')->setValue(NULL);
-    $this->assertNull($entity->name->value, format_string('%entity_type: Name field is not set.', array('%entity_type' => $entity_type)));
-    $this->assertNull($entity->user_id->target_id, format_string('%entity_type: User ID field is not set.', array('%entity_type' => $entity_type)));
-    $this->assertNull($entity->user_id->entity, format_string('%entity_type: User entity field is not set.', array('%entity_type' => $entity_type)));
+    $this->assertNull($entity->name->value, SafeMarkup::format('%entity_type: Name field is not set.', array('%entity_type' => $entity_type)));
+    $this->assertNull($entity->user_id->target_id, SafeMarkup::format('%entity_type: User ID field is not set.', array('%entity_type' => $entity_type)));
+    $this->assertNull($entity->user_id->entity, SafeMarkup::format('%entity_type: User entity field is not set.', array('%entity_type' => $entity_type)));
 
     // Create a fresh entity so target_id does not get its property object
     // instantiated, then verify setting a new value via typed data API works.
@@ -176,38 +177,38 @@ protected function doTestReadWrite($entity_type) {
     ));
     // Access the property object, and set a value.
     $entity2->user_id->first()->get('target_id')->setValue($new_user2->id());
-    $this->assertEqual($new_user2->id(), $entity2->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($new_user2->name->value, $entity2->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_user2->id(), $entity2->user_id->target_id, SafeMarkup::format('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_user2->name->value, $entity2->user_id->entity->name->value, SafeMarkup::format('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type)));
 
     // Test using isset(), empty() and unset().
     $entity->name->value = 'test unset';
     unset($entity->name->value);
-    $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
-    $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
-    $this->assertTrue(empty($entity->name->value), format_string('%entity_type: Name is empty.', array('%entity_type' => $entity_type)));
-    $this->assertTrue(empty($entity->name[0]->value), format_string('%entity_type: Name is empty.', array('%entity_type' => $entity_type)));
+    $this->assertFalse(isset($entity->name->value), SafeMarkup::format('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
+    $this->assertFalse(isset($entity->name[0]->value), SafeMarkup::format('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
+    $this->assertTrue(empty($entity->name->value), SafeMarkup::format('%entity_type: Name is empty.', array('%entity_type' => $entity_type)));
+    $this->assertTrue(empty($entity->name[0]->value), SafeMarkup::format('%entity_type: Name is empty.', array('%entity_type' => $entity_type)));
 
     $entity->name->value = 'a value';
-    $this->assertTrue(isset($entity->name->value), format_string('%entity_type: Name is set.', array('%entity_type' => $entity_type)));
-    $this->assertTrue(isset($entity->name[0]->value), format_string('%entity_type: Name is set.', array('%entity_type' => $entity_type)));
-    $this->assertFalse(empty($entity->name->value), format_string('%entity_type: Name is not empty.', array('%entity_type' => $entity_type)));
-    $this->assertFalse(empty($entity->name[0]->value), format_string('%entity_type: Name is not empty.', array('%entity_type' => $entity_type)));
-    $this->assertTrue(isset($entity->name[0]), format_string('%entity_type: Name string item is set.', array('%entity_type' => $entity_type)));
-    $this->assertFalse(isset($entity->name[1]), format_string('%entity_type: Second name string item is not set as it does not exist', array('%entity_type' => $entity_type)));
-    $this->assertTrue(isset($entity->name), format_string('%entity_type: Name field is set.', array('%entity_type' => $entity_type)));
-    $this->assertFalse(isset($entity->nameInvalid), format_string('%entity_type: Not existing field is not set.', array('%entity_type' => $entity_type)));
+    $this->assertTrue(isset($entity->name->value), SafeMarkup::format('%entity_type: Name is set.', array('%entity_type' => $entity_type)));
+    $this->assertTrue(isset($entity->name[0]->value), SafeMarkup::format('%entity_type: Name is set.', array('%entity_type' => $entity_type)));
+    $this->assertFalse(empty($entity->name->value), SafeMarkup::format('%entity_type: Name is not empty.', array('%entity_type' => $entity_type)));
+    $this->assertFalse(empty($entity->name[0]->value), SafeMarkup::format('%entity_type: Name is not empty.', array('%entity_type' => $entity_type)));
+    $this->assertTrue(isset($entity->name[0]), SafeMarkup::format('%entity_type: Name string item is set.', array('%entity_type' => $entity_type)));
+    $this->assertFalse(isset($entity->name[1]), SafeMarkup::format('%entity_type: Second name string item is not set as it does not exist', array('%entity_type' => $entity_type)));
+    $this->assertTrue(isset($entity->name), SafeMarkup::format('%entity_type: Name field is set.', array('%entity_type' => $entity_type)));
+    $this->assertFalse(isset($entity->nameInvalid), SafeMarkup::format('%entity_type: Not existing field is not set.', array('%entity_type' => $entity_type)));
 
     unset($entity->name[0]);
-    $this->assertFalse(isset($entity->name[0]), format_string('%entity_type: Name field item is not set.', array('%entity_type' => $entity_type)));
-    $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
-    $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
+    $this->assertFalse(isset($entity->name[0]), SafeMarkup::format('%entity_type: Name field item is not set.', array('%entity_type' => $entity_type)));
+    $this->assertFalse(isset($entity->name[0]->value), SafeMarkup::format('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
+    $this->assertFalse(isset($entity->name->value), SafeMarkup::format('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
 
     // Test emptying a field by assigning an empty value. NULL and array()
     // behave the same.
     foreach ([NULL, array(), 'unset'] as $empty) {
       // Make sure a value is present
       $entity->name->value = 'a value';
-      $this->assertTrue(isset($entity->name->value), format_string('%entity_type: Name is set.', array('%entity_type' => $entity_type)));
+      $this->assertTrue(isset($entity->name->value), SafeMarkup::format('%entity_type: Name is set.', array('%entity_type' => $entity_type)));
       // Now, empty the field.
       if ($empty === 'unset') {
         unset($entity->name);
@@ -215,36 +216,36 @@ protected function doTestReadWrite($entity_type) {
       else {
         $entity->name = $empty;
       }
-      $this->assertTrue(isset($entity->name), format_string('%entity_type: Name field is set.', array('%entity_type' => $entity_type)));
-      $this->assertTrue($entity->name->isEmpty(), format_string('%entity_type: Name field is set.', array('%entity_type' => $entity_type)));
-      $this->assertIdentical(count($entity->name), 0, format_string('%entity_type: Name field contains no items.', array('%entity_type' => $entity_type)));
-      $this->assertIdentical($entity->name->getValue(), array(), format_string('%entity_type: Name field value is an empty array.', array('%entity_type' => $entity_type)));
-      $this->assertFalse(isset($entity->name[0]), format_string('%entity_type: Name field item is not set.', array('%entity_type' => $entity_type)));
-      $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: First name item value is not set.', array('%entity_type' => $entity_type)));
-      $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name value is not set.', array('%entity_type' => $entity_type)));
+      $this->assertTrue(isset($entity->name), SafeMarkup::format('%entity_type: Name field is set.', array('%entity_type' => $entity_type)));
+      $this->assertTrue($entity->name->isEmpty(), SafeMarkup::format('%entity_type: Name field is set.', array('%entity_type' => $entity_type)));
+      $this->assertIdentical(count($entity->name), 0, SafeMarkup::format('%entity_type: Name field contains no items.', array('%entity_type' => $entity_type)));
+      $this->assertIdentical($entity->name->getValue(), array(), SafeMarkup::format('%entity_type: Name field value is an empty array.', array('%entity_type' => $entity_type)));
+      $this->assertFalse(isset($entity->name[0]), SafeMarkup::format('%entity_type: Name field item is not set.', array('%entity_type' => $entity_type)));
+      $this->assertFalse(isset($entity->name[0]->value), SafeMarkup::format('%entity_type: First name item value is not set.', array('%entity_type' => $entity_type)));
+      $this->assertFalse(isset($entity->name->value), SafeMarkup::format('%entity_type: Name value is not set.', array('%entity_type' => $entity_type)));
     }
 
     // Access the language field.
     $langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
-    $this->assertEqual($langcode, $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual(\Drupal::languageManager()->getLanguage($langcode), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($langcode, $entity->{$langcode_key}->value, SafeMarkup::format('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(\Drupal::languageManager()->getLanguage($langcode), $entity->{$langcode_key}->language, SafeMarkup::format('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
 
     // Change the language by code.
     $entity->{$langcode_key}->value = \Drupal::languageManager()->getDefaultLanguage()->getId();
-    $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, SafeMarkup::format('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, SafeMarkup::format('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
 
     // Revert language by code then try setting it by language object.
     $entity->{$langcode_key}->value = $langcode;
     $entity->{$langcode_key}->language = \Drupal::languageManager()->getDefaultLanguage();
-    $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, SafeMarkup::format('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, SafeMarkup::format('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
 
     // Access the text field and test updating.
-    $this->assertEqual($entity->field_test_text->value, $this->entity_field_text, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->field_test_text->value, $this->entity_field_text, SafeMarkup::format('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
     $new_text = $this->randomMachineName();
     $entity->field_test_text->value = $new_text;
-    $this->assertEqual($entity->field_test_text->value, $new_text, format_string('%entity_type: Updated text field can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->field_test_text->value, $new_text, SafeMarkup::format('%entity_type: Updated text field can be read.', array('%entity_type' => $entity_type)));
 
     // Test creating the entity by passing in plain values.
     $this->entity_name = $this->randomMachineName();
@@ -259,70 +260,70 @@ protected function doTestReadWrite($entity_type) {
       'user_id' => $user_item,
       'field_test_text' => $text_item,
     ));
-    $this->assertEqual($this->entity_name, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($this->entity_user->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_name, $entity->name->value, SafeMarkup::format('%entity_type: Name value can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, SafeMarkup::format('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_user->getUsername(), $entity->user_id->entity->name->value, SafeMarkup::format('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, SafeMarkup::format('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
 
     // Tests copying field values by assigning the TypedData objects.
     $entity2 = $this->createTestEntity($entity_type);
     $entity2->name = $entity->name;
     $entity2->user_id = $entity->user_id;
     $entity2->field_test_text = $entity->field_test_text;
-    $this->assertFalse($entity->name === $entity2->name, format_string('%entity_type: Copying properties results in a different field object.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($entity->name->value, $entity2->name->value, format_string('%entity_type: Name field copied.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($entity->user_id->target_id, $entity2->user_id->target_id, format_string('%entity_type: User id field copied.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($entity->field_test_text->value, $entity2->field_test_text->value, format_string('%entity_type: Text field copied.', array('%entity_type' => $entity_type)));
+    $this->assertFalse($entity->name === $entity2->name, SafeMarkup::format('%entity_type: Copying properties results in a different field object.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name->value, $entity2->name->value, SafeMarkup::format('%entity_type: Name field copied.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->user_id->target_id, $entity2->user_id->target_id, SafeMarkup::format('%entity_type: User id field copied.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->field_test_text->value, $entity2->field_test_text->value, SafeMarkup::format('%entity_type: Text field copied.', array('%entity_type' => $entity_type)));
 
     // Tests that assigning TypedData objects to non-field properties keeps the
     // assigned value as is.
     $entity2 = $this->createTestEntity($entity_type);
     $entity2->_not_a_field = $entity->name;
-    $this->assertTrue($entity2->_not_a_field === $entity->name, format_string('%entity_type: Typed data objects can be copied to non-field properties as is.', array('%entity_type' => $entity_type)));
+    $this->assertTrue($entity2->_not_a_field === $entity->name, SafeMarkup::format('%entity_type: Typed data objects can be copied to non-field properties as is.', array('%entity_type' => $entity_type)));
 
     // Tests adding a value to a field item list.
     $entity->name[] = 'Another name';
-    $this->assertEqual($entity->name[1]->value, 'Another name', format_string('%entity_type: List item added via [] and the first property.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name[1]->value, 'Another name', SafeMarkup::format('%entity_type: List item added via [] and the first property.', array('%entity_type' => $entity_type)));
     $entity->name[] = array('value' => 'Third name');
-    $this->assertEqual($entity->name[2]->value, 'Third name', format_string('%entity_type: List item added via [] and an array of properties.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name[2]->value, 'Third name', SafeMarkup::format('%entity_type: List item added via [] and an array of properties.', array('%entity_type' => $entity_type)));
     $entity->name[3] = array('value' => 'Fourth name');
-    $this->assertEqual($entity->name[3]->value, 'Fourth name', format_string('%entity_type: List item added via offset and an array of properties.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name[3]->value, 'Fourth name', SafeMarkup::format('%entity_type: List item added via offset and an array of properties.', array('%entity_type' => $entity_type)));
     unset($entity->name[3]);
 
     // Test removing and empty-ing list items.
-    $this->assertEqual(count($entity->name), 3, format_string('%entity_type: List has 3 items.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entity->name), 3, SafeMarkup::format('%entity_type: List has 3 items.', array('%entity_type' => $entity_type)));
     unset($entity->name[1]);
-    $this->assertEqual(count($entity->name), 2, format_string('%entity_type: Second list item has been removed.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($entity->name[1]->value, 'Third name', format_string('%entity_type: The subsequent items have been shifted up.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($entity->name[1]->getName(), 1, format_string('%entity_type: The items names have been updated to their new delta.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entity->name), 2, SafeMarkup::format('%entity_type: Second list item has been removed.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name[1]->value, 'Third name', SafeMarkup::format('%entity_type: The subsequent items have been shifted up.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name[1]->getName(), 1, SafeMarkup::format('%entity_type: The items names have been updated to their new delta.', array('%entity_type' => $entity_type)));
     $entity->name[1] = NULL;
-    $this->assertEqual(count($entity->name), 2, format_string('%entity_type: Assigning NULL does not reduce array count.', array('%entity_type' => $entity_type)));
-    $this->assertTrue($entity->name[1]->isEmpty(), format_string('%entity_type: Assigning NULL empties the item.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entity->name), 2, SafeMarkup::format('%entity_type: Assigning NULL does not reduce array count.', array('%entity_type' => $entity_type)));
+    $this->assertTrue($entity->name[1]->isEmpty(), SafeMarkup::format('%entity_type: Assigning NULL empties the item.', array('%entity_type' => $entity_type)));
 
     // Test using isEmpty().
     unset($entity->name[1]);
-    $this->assertFalse($entity->name[0]->isEmpty(), format_string('%entity_type: Name item is not empty.', array('%entity_type' => $entity_type)));
+    $this->assertFalse($entity->name[0]->isEmpty(), SafeMarkup::format('%entity_type: Name item is not empty.', array('%entity_type' => $entity_type)));
     $entity->name->value = NULL;
-    $this->assertTrue($entity->name[0]->isEmpty(), format_string('%entity_type: Name item is empty.', array('%entity_type' => $entity_type)));
-    $this->assertTrue($entity->name->isEmpty(), format_string('%entity_type: Name field is empty.', array('%entity_type' => $entity_type)));
-    $this->assertEqual(count($entity->name), 1, format_string('%entity_type: Empty item is considered when counting.', array('%entity_type' => $entity_type)));
-    $this->assertEqual(count(iterator_to_array($entity->name->getIterator())), count($entity->name), format_string('%entity_type: Count matches iterator count.', array('%entity_type' => $entity_type)));
-    $this->assertTrue($entity->name->getValue() === array(0 => array('value' => NULL)), format_string('%entity_type: Name field value contains a NULL value.', array('%entity_type' => $entity_type)));
+    $this->assertTrue($entity->name[0]->isEmpty(), SafeMarkup::format('%entity_type: Name item is empty.', array('%entity_type' => $entity_type)));
+    $this->assertTrue($entity->name->isEmpty(), SafeMarkup::format('%entity_type: Name field is empty.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entity->name), 1, SafeMarkup::format('%entity_type: Empty item is considered when counting.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count(iterator_to_array($entity->name->getIterator())), count($entity->name), SafeMarkup::format('%entity_type: Count matches iterator count.', array('%entity_type' => $entity_type)));
+    $this->assertTrue($entity->name->getValue() === array(0 => array('value' => NULL)), SafeMarkup::format('%entity_type: Name field value contains a NULL value.', array('%entity_type' => $entity_type)));
 
     // Test using filterEmptyItems().
     $entity->name = array(NULL, 'foo');
-    $this->assertEqual(count($entity->name), 2, format_string('%entity_type: List has 2 items.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entity->name), 2, SafeMarkup::format('%entity_type: List has 2 items.', array('%entity_type' => $entity_type)));
     $entity->name->filterEmptyItems();
-    $this->assertEqual(count($entity->name), 1, format_string('%entity_type: The empty item was removed.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($entity->name[0]->value, 'foo', format_string('%entity_type: The items were renumbered.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($entity->name[0]->getName(), 0, format_string('%entity_type: The deltas were updated in the items.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entity->name), 1, SafeMarkup::format('%entity_type: The empty item was removed.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name[0]->value, 'foo', SafeMarkup::format('%entity_type: The items were renumbered.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name[0]->getName(), 0, SafeMarkup::format('%entity_type: The deltas were updated in the items.', array('%entity_type' => $entity_type)));
 
     // Test get and set field values.
     $entity->name = 'foo';
-    $this->assertEqual($entity->name[0]->toArray(), array('value' => 'foo'), format_string('%entity_type: Field value has been retrieved via toArray()', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->name[0]->toArray(), array('value' => 'foo'), SafeMarkup::format('%entity_type: Field value has been retrieved via toArray()', array('%entity_type' => $entity_type)));
 
     $values = $entity->toArray();
-    $this->assertEqual($values['name'], array(0 => array('value' => 'foo')), format_string('%entity_type: Field value has been retrieved via toArray() from an entity.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($values['name'], array(0 => array('value' => 'foo')), SafeMarkup::format('%entity_type: Field value has been retrieved via toArray() from an entity.', array('%entity_type' => $entity_type)));
 
     // Make sure the user id can be set to zero.
     $user_item[0]['target_id'] = 0;
@@ -331,8 +332,8 @@ protected function doTestReadWrite($entity_type) {
       'user_id' => $user_item,
       'field_test_text' => $text_item,
     ));
-    $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', array('%entity_type' => $entity_type)));
-    $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type)));
+    $this->assertNotNull($entity->user_id->target_id, SafeMarkup::format('%entity_type: User id is not NULL', array('%entity_type' => $entity_type)));
+    $this->assertIdentical($entity->user_id->target_id, 0, SafeMarkup::format('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type)));
 
     // Test setting the ID with the value only.
     $entity = entity_create($entity_type, array(
@@ -340,8 +341,8 @@ protected function doTestReadWrite($entity_type) {
       'user_id' => 0,
       'field_test_text' => $text_item,
     ));
-    $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', array('%entity_type' => $entity_type)));
-    $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type)));
+    $this->assertNotNull($entity->user_id->target_id, SafeMarkup::format('%entity_type: User id is not NULL', array('%entity_type' => $entity_type)));
+    $this->assertIdentical($entity->user_id->target_id, 0, SafeMarkup::format('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type)));
   }
 
   /**
@@ -364,19 +365,19 @@ protected function doTestSave($entity_type) {
     $langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
     $entity = $this->createTestEntity($entity_type);
     $entity->save();
-    $this->assertTrue((bool) $entity->id(), format_string('%entity_type: Entity has received an id.', array('%entity_type' => $entity_type)));
+    $this->assertTrue((bool) $entity->id(), SafeMarkup::format('%entity_type: Entity has received an id.', array('%entity_type' => $entity_type)));
 
     $entity = entity_load($entity_type, $entity->id());
-    $this->assertTrue((bool) $entity->id(), format_string('%entity_type: Entity loaded.', array('%entity_type' => $entity_type)));
+    $this->assertTrue((bool) $entity->id(), SafeMarkup::format('%entity_type: Entity loaded.', array('%entity_type' => $entity_type)));
 
     // Access the name field.
-    $this->assertEqual(1, $entity->id->value, format_string('%entity_type: ID value can be read.', array('%entity_type' => $entity_type)));
-    $this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual('en', $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual(\Drupal::languageManager()->getLanguage('en'), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($this->entity_user->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(1, $entity->id->value, SafeMarkup::format('%entity_type: ID value can be read.', array('%entity_type' => $entity_type)));
+    $this->assertTrue(is_string($entity->uuid->value), SafeMarkup::format('%entity_type: UUID value can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual('en', $entity->{$langcode_key}->value, SafeMarkup::format('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(\Drupal::languageManager()->getLanguage('en'), $entity->{$langcode_key}->language, SafeMarkup::format('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, SafeMarkup::format('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_user->getUsername(), $entity->user_id->entity->name->value, SafeMarkup::format('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, SafeMarkup::format('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
   }
 
   /**
@@ -516,8 +517,8 @@ protected function doTestIterator($entity_type) {
     }
 
     $fields = $entity->getFields();
-    $this->assertEqual(array_keys($fields), array_keys($entity->getTypedData()->getDataDefinition()->getPropertyDefinitions()), format_string('%entity_type: All fields returned.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($fields, iterator_to_array($entity->getIterator()), format_string('%entity_type: Entity iterator iterates over all fields.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(array_keys($fields), array_keys($entity->getTypedData()->getDataDefinition()->getPropertyDefinitions()), SafeMarkup::format('%entity_type: All fields returned.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($fields, iterator_to_array($entity->getIterator()), SafeMarkup::format('%entity_type: Entity iterator iterates over all fields.', array('%entity_type' => $entity_type)));
   }
 
   /**
@@ -559,7 +560,7 @@ protected function doTestDataStructureInterfaces($entity_type) {
     );
     asort($strings);
     asort($target_strings);
-    $this->assertEqual(array_values($strings), array_values($target_strings), format_string('%entity_type: All contained strings found.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(array_values($strings), array_values($target_strings), SafeMarkup::format('%entity_type: All contained strings found.', array('%entity_type' => $entity_type)));
   }
 
   /**
@@ -727,12 +728,12 @@ protected function doTestComputedProperties($entity_type) {
     $entity->field_test_text->format = filter_default_format();
 
     $target = "<p>The &lt;strong&gt;text&lt;/strong&gt; text to filter.</p>\n";
-    $this->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->field_test_text->processed, $target, SafeMarkup::format('%entity_type: Text is processed with the default filter.', array('%entity_type' => $entity_type)));
 
     // Save and load entity and make sure it still works.
     $entity->save();
     $entity = entity_load($entity_type, $entity->id());
-    $this->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->field_test_text->processed, $target, SafeMarkup::format('%entity_type: Text is processed with the default filter.', array('%entity_type' => $entity_type)));
   }
 
 }
diff --git a/core/modules/system/src/Tests/Entity/EntityFormTest.php b/core/modules/system/src/Tests/Entity/EntityFormTest.php
index 307b69a..8f955d7 100644
--- a/core/modules/system/src/Tests/Entity/EntityFormTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityFormTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -67,21 +68,21 @@ protected function doTestFormCRUD($entity_type) {
 
     $this->drupalPostForm($entity_type . '/add', $edit, t('Save'));
     $entity = $this->loadEntityByName($entity_type, $name1);
-    $this->assertTrue($entity, format_string('%entity_type: Entity found in the database.', array('%entity_type' => $entity_type)));
+    $this->assertTrue($entity, SafeMarkup::format('%entity_type: Entity found in the database.', array('%entity_type' => $entity_type)));
 
     $edit['name[0][value]'] = $name2;
     $this->drupalPostForm($entity_type . '/manage/' . $entity->id(), $edit, t('Save'));
     $entity = $this->loadEntityByName($entity_type, $name1);
-    $this->assertFalse($entity, format_string('%entity_type: The entity has been modified.', array('%entity_type' => $entity_type)));
+    $this->assertFalse($entity, SafeMarkup::format('%entity_type: The entity has been modified.', array('%entity_type' => $entity_type)));
     $entity = $this->loadEntityByName($entity_type, $name2);
-    $this->assertTrue($entity, format_string('%entity_type: Modified entity found in the database.', array('%entity_type' => $entity_type)));
-    $this->assertNotEqual($entity->name->value, $name1, format_string('%entity_type: The entity name has been modified.', array('%entity_type' => $entity_type)));
+    $this->assertTrue($entity, SafeMarkup::format('%entity_type: Modified entity found in the database.', array('%entity_type' => $entity_type)));
+    $this->assertNotEqual($entity->name->value, $name1, SafeMarkup::format('%entity_type: The entity name has been modified.', array('%entity_type' => $entity_type)));
 
     $this->drupalGet($entity_type . '/manage/' . $entity->id());
     $this->clickLink(t('Delete'));
     $this->drupalPostForm(NULL, array(), t('Delete'));
     $entity = $this->loadEntityByName($entity_type, $name2);
-    $this->assertFalse($entity, format_string('%entity_type: Entity not found in the database.', array('%entity_type' => $entity_type)));
+    $this->assertFalse($entity, SafeMarkup::format('%entity_type: Entity not found in the database.', array('%entity_type' => $entity_type)));
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Entity/EntityOperationsTest.php b/core/modules/system/src/Tests/Entity/EntityOperationsTest.php
index 4593bd9..2f86207 100644
--- a/core/modules/system/src/Tests/Entity/EntityOperationsTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityOperationsTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -44,7 +45,7 @@ public function testEntityOperationAlter() {
     $roles = user_roles();
     foreach ($roles as $role) {
       $this->assertLinkByHref($role->url() . '/test_operation');
-      $this->assertLink(format_string('Test Operation: @label', array('@label' => $role->label())));
+      $this->assertLink(SafeMarkup::format('Test Operation: @label', array('@label' => $role->label())));
     }
   }
 
diff --git a/core/modules/system/src/Tests/Entity/EntityQueryTest.php b/core/modules/system/src/Tests/Entity/EntityQueryTest.php
index f66ab4e..1590845 100644
--- a/core/modules/system/src/Tests/Entity/EntityQueryTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityQueryTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\entity_test\Entity\EntityTestMulRev;
@@ -485,7 +486,7 @@ protected function assertBundleOrder($order) {
           }
         }
       }
-      $this->assertTrue($ok, format_string("$i is after all entities in bundle2"));
+      $this->assertTrue($ok, SafeMarkup::format("$i is after all entities in bundle2"));
     }
   }
 
diff --git a/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
index b7bf65e..67477ab 100644
--- a/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
@@ -52,7 +52,7 @@ protected function assertReferenceable(array $selection_options, $tests, $handle
     foreach ($tests as $test) {
       foreach ($test['arguments'] as $arguments) {
         $result = call_user_func_array(array($handler, 'getReferenceableEntities'), $arguments);
-        $this->assertEqual($result, $test['result'], format_string('Valid result set returned by @handler.', array('@handler' => $handler_name)));
+        $this->assertEqual($result, $test['result'], SafeMarkup::format('Valid result set returned by @handler.', array('@handler' => $handler_name)));
 
         $result = call_user_func_array(array($handler, 'countReferenceableEntities'), $arguments);
         if (!empty($test['result'])) {
@@ -63,7 +63,7 @@ protected function assertReferenceable(array $selection_options, $tests, $handle
           $count = 0;
         }
 
-        $this->assertEqual($result, $count, format_string('Valid count returned by @handler.', array('@handler' => $handler_name)));
+        $this->assertEqual($result, $count, SafeMarkup::format('Valid count returned by @handler.', array('@handler' => $handler_name)));
       }
     }
   }
diff --git a/core/modules/system/src/Tests/Entity/EntityRevisionsTest.php b/core/modules/system/src/Tests/Entity/EntityRevisionsTest.php
index 06168a2..f2ae956 100644
--- a/core/modules/system/src/Tests/Entity/EntityRevisionsTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityRevisionsTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -82,9 +83,9 @@ protected function assertRevisions($entity_type) {
       $revision_ids[] = $entity->revision_id->value;
 
       // Check that the fields and properties contain new content.
-      $this->assertTrue($entity->revision_id->value > $legacy_revision_id, format_string('%entity_type: Revision ID changed.', array('%entity_type' => $entity_type)));
-      $this->assertNotEqual($entity->name->value, $legacy_name, format_string('%entity_type: Name changed.', array('%entity_type' => $entity_type)));
-      $this->assertNotEqual($entity->field_test_text->value, $legacy_text, format_string('%entity_type: Text changed.', array('%entity_type' => $entity_type)));
+      $this->assertTrue($entity->revision_id->value > $legacy_revision_id, SafeMarkup::format('%entity_type: Revision ID changed.', array('%entity_type' => $entity_type)));
+      $this->assertNotEqual($entity->name->value, $legacy_name, SafeMarkup::format('%entity_type: Name changed.', array('%entity_type' => $entity_type)));
+      $this->assertNotEqual($entity->field_test_text->value, $legacy_text, SafeMarkup::format('%entity_type: Text changed.', array('%entity_type' => $entity_type)));
     }
 
     for ($i = 0; $i < $revision_count; $i++) {
@@ -92,19 +93,19 @@ protected function assertRevisions($entity_type) {
       $entity_revision = entity_revision_load($entity_type, $revision_ids[$i]);
 
       // Check if properties and fields contain the revision specific content.
-      $this->assertEqual($entity_revision->revision_id->value, $revision_ids[$i], format_string('%entity_type: Revision ID matches.', array('%entity_type' => $entity_type)));
-      $this->assertEqual($entity_revision->name->value, $names[$i], format_string('%entity_type: Name matches.', array('%entity_type' => $entity_type)));
-      $this->assertEqual($entity_revision->field_test_text->value, $texts[$i], format_string('%entity_type: Text matches.', array('%entity_type' => $entity_type)));
+      $this->assertEqual($entity_revision->revision_id->value, $revision_ids[$i], SafeMarkup::format('%entity_type: Revision ID matches.', array('%entity_type' => $entity_type)));
+      $this->assertEqual($entity_revision->name->value, $names[$i], SafeMarkup::format('%entity_type: Name matches.', array('%entity_type' => $entity_type)));
+      $this->assertEqual($entity_revision->field_test_text->value, $texts[$i], SafeMarkup::format('%entity_type: Text matches.', array('%entity_type' => $entity_type)));
 
       // Check non-revisioned values are loaded.
-      $this->assertTrue(isset($entity_revision->created->value), format_string('%entity_type: Non-revisioned field is loaded.', array('%entity_type' => $entity_type)));
-      $this->assertEqual($entity_revision->created->value, $created[2], format_string('%entity_type: Non-revisioned field value is the same between revisions.', array('%entity_type' => $entity_type)));
+      $this->assertTrue(isset($entity_revision->created->value), SafeMarkup::format('%entity_type: Non-revisioned field is loaded.', array('%entity_type' => $entity_type)));
+      $this->assertEqual($entity_revision->created->value, $created[2], SafeMarkup::format('%entity_type: Non-revisioned field value is the same between revisions.', array('%entity_type' => $entity_type)));
     }
 
     // Confirm the correct revision text appears in the edit form.
     $entity = entity_load($entity_type, $entity->id->value);
     $this->drupalGet($entity_type . '/manage/' . $entity->id->value);
-    $this->assertFieldById('edit-name-0-value', $entity->name->value, format_string('%entity_type: Name matches in UI.', array('%entity_type' => $entity_type)));
-    $this->assertFieldById('edit-field-test-text-0-value', $entity->field_test_text->value, format_string('%entity_type: Text matches in UI.', array('%entity_type' => $entity_type)));
+    $this->assertFieldById('edit-name-0-value', $entity->name->value, SafeMarkup::format('%entity_type: Name matches in UI.', array('%entity_type' => $entity_type)));
+    $this->assertFieldById('edit-field-test-text-0-value', $entity->field_test_text->value, SafeMarkup::format('%entity_type: Text matches in UI.', array('%entity_type' => $entity_type)));
   }
 }
diff --git a/core/modules/system/src/Tests/Entity/EntitySchemaTest.php b/core/modules/system/src/Tests/Entity/EntitySchemaTest.php
index 5bd22ed..5e88811 100644
--- a/core/modules/system/src/Tests/Entity/EntitySchemaTest.php
+++ b/core/modules/system/src/Tests/Entity/EntitySchemaTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 /**
@@ -99,27 +100,27 @@ public function testEntitySchemaUpdate() {
     // Initially only the base table and the dedicated field data table should
     // exist.
     foreach ($tables as $index => $table) {
-      $this->assertEqual($schema_handler->tableExists($table), !$index, String::format('Entity schema correct for the @table table.', array('@table' => $table)));
+      $this->assertEqual($schema_handler->tableExists($table), !$index, SafeMarkup::format('Entity schema correct for the @table table.', array('@table' => $table)));
     }
-    $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), String::format('Field schema correct for the @table table.', array('@table' => $table)));
+    $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), SafeMarkup::format('Field schema correct for the @table table.', array('@table' => $table)));
 
     // Update the entity type definition and check that the entity schema now
     // supports translations and revisions.
     $this->updateEntityType(TRUE);
     foreach ($tables as $table) {
-      $this->assertTrue($schema_handler->tableExists($table), String::format('Entity schema correct for the @table table.', array('@table' => $table)));
+      $this->assertTrue($schema_handler->tableExists($table), SafeMarkup::format('Entity schema correct for the @table table.', array('@table' => $table)));
     }
     foreach ($dedicated_tables as $table) {
-      $this->assertTrue($schema_handler->tableExists($table), String::format('Field schema correct for the @table table.', array('@table' => $table)));
+      $this->assertTrue($schema_handler->tableExists($table), SafeMarkup::format('Field schema correct for the @table table.', array('@table' => $table)));
     }
 
     // Revert changes and check that the entity schema now does not support
     // neither translations nor revisions.
     $this->updateEntityType(FALSE);
     foreach ($tables as $index => $table) {
-      $this->assertEqual($schema_handler->tableExists($table), !$index, String::format('Entity schema correct for the @table table.', array('@table' => $table)));
+      $this->assertEqual($schema_handler->tableExists($table), !$index, SafeMarkup::format('Entity schema correct for the @table table.', array('@table' => $table)));
     }
-    $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), String::format('Field schema correct for the @table table.', array('@table' => $table)));
+    $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), SafeMarkup::format('Field schema correct for the @table table.', array('@table' => $table)));
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Entity/EntityTranslationTest.php b/core/modules/system/src/Tests/Entity/EntityTranslationTest.php
index aab0d28..eb7b895 100644
--- a/core/modules/system/src/Tests/Entity/EntityTranslationTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityTranslationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\ContentEntityInterface;
 use Drupal\Core\Language\LanguageInterface;
@@ -42,55 +43,55 @@ protected function doTestEntityLanguageMethods($entity_type) {
       'name' => 'test',
       'user_id' => $this->container->get('current_user')->id(),
     ));
-    $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->getId(), format_string('%entity_type: Entity created with API has default language.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->getId(), SafeMarkup::format('%entity_type: Entity created with API has default language.', array('%entity_type' => $entity_type)));
     $entity = entity_create($entity_type, array(
       'name' => 'test',
       'user_id' => \Drupal::currentUser()->id(),
       $langcode_key => LanguageInterface::LANGCODE_NOT_SPECIFIED,
     ));
-    $this->assertEqual($entity->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type)));
-    $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED, SafeMarkup::format('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type)));
+    $this->assertFalse($entity->getTranslationLanguages(FALSE), SafeMarkup::format('%entity_type: No translations are available', array('%entity_type' => $entity_type)));
 
     // Set the value in default language.
     $entity->set($this->field_name, array(0 => array('value' => 'default value')));
     // Get the value.
     $field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get($this->field_name);
-    $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($field->value, 'default value', SafeMarkup::format('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, SafeMarkup::format('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
 
     // Set the value in a certain language. As the entity is not
     // language-specific it should use the default language and so ignore the
     // specified language.
     $entity->getTranslation($this->langcodes[1])->set($this->field_name, array(0 => array('value' => 'default value2')));
-    $this->assertEqual($entity->get($this->field_name)->value, 'default value2', format_string('%entity_type: Untranslated value updated.', array('%entity_type' => $entity_type)));
-    $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->get($this->field_name)->value, 'default value2', SafeMarkup::format('%entity_type: Untranslated value updated.', array('%entity_type' => $entity_type)));
+    $this->assertFalse($entity->getTranslationLanguages(FALSE), SafeMarkup::format('%entity_type: No translations are available', array('%entity_type' => $entity_type)));
 
     // Test getting a field value using a specific language for a not
     // language-specific entity.
     $field = $entity->getTranslation($this->langcodes[1])->get($this->field_name);
-    $this->assertEqual($field->value, 'default value2', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($field->value, 'default value2', SafeMarkup::format('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, SafeMarkup::format('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
 
     // Now, make the entity language-specific by assigning a language and test
     // translating it.
     $default_langcode = $this->langcodes[0];
     $entity->{$langcode_key}->value = $default_langcode;
     $entity->{$this->field_name} = array();
-    $this->assertEqual($entity->language(), \Drupal::languageManager()->getLanguage($this->langcodes[0]), format_string('%entity_type: Entity language retrieved.', array('%entity_type' => $entity_type)));
-    $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type)));
+    $this->assertEqual($entity->language(), \Drupal::languageManager()->getLanguage($this->langcodes[0]), SafeMarkup::format('%entity_type: Entity language retrieved.', array('%entity_type' => $entity_type)));
+    $this->assertFalse($entity->getTranslationLanguages(FALSE), SafeMarkup::format('%entity_type: No translations are available', array('%entity_type' => $entity_type)));
 
     // Set the value in default language.
     $entity->set($this->field_name, array(0 => array('value' => 'default value')));
     // Get the value.
     $field = $entity->get($this->field_name);
-    $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($field->getLangcode(), $default_langcode, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($field->value, 'default value', SafeMarkup::format('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($field->getLangcode(), $default_langcode, SafeMarkup::format('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
 
     // Set a translation.
     $entity->getTranslation($this->langcodes[1])->set($this->field_name, array(0 => array('value' => 'translation 1')));
     $field = $entity->getTranslation($this->langcodes[1])->{$this->field_name};
-    $this->assertEqual($field->value, 'translation 1', format_string('%entity_type: Translated value set.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($field->getLangcode(), $this->langcodes[1], format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($field->value, 'translation 1', SafeMarkup::format('%entity_type: Translated value set.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($field->getLangcode(), $this->langcodes[1], SafeMarkup::format('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
 
     // Make sure the untranslated value stays.
     $field = $entity->get($this->field_name);
@@ -101,7 +102,7 @@ protected function doTestEntityLanguageMethods($entity_type) {
     $this->assertEqual($entity->getTranslationLanguages(FALSE), $translations, 'Translations retrieved.');
 
     // Try to get a not available translation.
-    $this->assertNull($entity->getTranslation($this->langcodes[2])->get($this->field_name)->value, format_string('%entity_type: A translation that is not available is NULL.', array('%entity_type' => $entity_type)));
+    $this->assertNull($entity->getTranslation($this->langcodes[2])->get($this->field_name)->value, SafeMarkup::format('%entity_type: A translation that is not available is NULL.', array('%entity_type' => $entity_type)));
 
     // Try to get a value using an invalid language code.
     try {
@@ -115,10 +116,10 @@ protected function doTestEntityLanguageMethods($entity_type) {
     // Try to set a value using an invalid language code.
     try {
       $entity->getTranslation('invalid')->set($this->field_name, NULL);
-      $this->fail(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', array('%entity_type' => $entity_type)));
+      $this->fail(SafeMarkup::format('%entity_type: Setting a translation for an invalid language throws an exception.', array('%entity_type' => $entity_type)));
     }
     catch (\InvalidArgumentException $e) {
-      $this->pass(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', array('%entity_type' => $entity_type)));
+      $this->pass(SafeMarkup::format('%entity_type: Setting a translation for an invalid language throws an exception.', array('%entity_type' => $entity_type)));
     }
 
     // Set the value in default language.
@@ -126,8 +127,8 @@ protected function doTestEntityLanguageMethods($entity_type) {
     $entity->getTranslation($this->langcodes[1])->set($field_name, array(0 => array('value' => 'default value2')));
     // Get the value.
     $field = $entity->get($field_name);
-    $this->assertEqual($field->value, 'default value2', format_string('%entity_type: Untranslated value set into a translation in non-strict mode.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($field->getLangcode(), $default_langcode, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($field->value, 'default value2', SafeMarkup::format('%entity_type: Untranslated value set into a translation in non-strict mode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($field->getLangcode(), $default_langcode, SafeMarkup::format('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
   }
 
   /**
@@ -159,19 +160,19 @@ protected function doTestMultilingualProperties($entity_type) {
     $entity->save();
     $entity = entity_load($entity_type, $entity->id());
     $default_langcode = $entity->language()->getId();
-    $this->assertEqual($default_langcode, LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($default_langcode, LanguageInterface::LANGCODE_NOT_SPECIFIED, SafeMarkup::format('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type)));
     $field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('name');
-    $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($uid, $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as language neutral.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($name, $field->value, SafeMarkup::format('%entity_type: The entity name has been correctly stored as language neutral.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($default_langcode, $field->getLangcode(), SafeMarkup::format('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($uid, $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('user_id')->target_id, SafeMarkup::format('%entity_type: The entity author has been correctly stored as language neutral.', array('%entity_type' => $entity_type)));
     $field = $entity->getTranslation($langcode)->get('name');
-    $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name defaults to neutral language.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to neutral language.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($name, $field->value, SafeMarkup::format('%entity_type: The entity name defaults to neutral language.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($default_langcode, $field->getLangcode(), SafeMarkup::format('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, SafeMarkup::format('%entity_type: The entity author defaults to neutral language.', array('%entity_type' => $entity_type)));
     $field = $entity->get('name');
-    $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($uid, $entity->get('user_id')->target_id, format_string('%entity_type: The entity author can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($name, $field->value, SafeMarkup::format('%entity_type: The entity name can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($default_langcode, $field->getLangcode(), SafeMarkup::format('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($uid, $entity->get('user_id')->target_id, SafeMarkup::format('%entity_type: The entity author can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
 
     // Create a language-aware entity and check that properties are stored
     // as language-aware.
@@ -179,21 +180,21 @@ protected function doTestMultilingualProperties($entity_type) {
     $entity->save();
     $entity = entity_load($entity_type, $entity->id());
     $default_langcode = $entity->language()->getId();
-    $this->assertEqual($default_langcode, $langcode, format_string('%entity_type: Entity created as language specific.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($default_langcode, $langcode, SafeMarkup::format('%entity_type: Entity created as language specific.', array('%entity_type' => $entity_type)));
     $field = $entity->getTranslation($langcode)->get('name');
-    $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($name, $field->value, SafeMarkup::format('%entity_type: The entity name has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($default_langcode, $field->getLangcode(), SafeMarkup::format('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, SafeMarkup::format('%entity_type: The entity author has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type)));
     // Translatable properties on a translatable entity should use default
     // language if LanguageInterface::LANGCODE_NOT_SPECIFIED is passed.
     $field = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get('name');
-    $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name defaults to the default language.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($uid, $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to the default language.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($name, $field->value, SafeMarkup::format('%entity_type: The entity name defaults to the default language.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($default_langcode, $field->getLangcode(), SafeMarkup::format('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($uid, $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get('user_id')->target_id, SafeMarkup::format('%entity_type: The entity author defaults to the default language.', array('%entity_type' => $entity_type)));
     $field = $entity->get('name');
-    $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($uid, $entity->get('user_id')->target_id, format_string('%entity_type: The entity author can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($name, $field->value, SafeMarkup::format('%entity_type: The entity name can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($default_langcode, $field->getLangcode(), SafeMarkup::format('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($uid, $entity->get('user_id')->target_id, SafeMarkup::format('%entity_type: The entity author can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
 
     // Create property translations.
     $properties = array();
@@ -226,10 +227,10 @@ protected function doTestMultilingualProperties($entity_type) {
         '%langcode' => $langcode,
       );
       $field = $entity->getTranslation($langcode)->get('name');
-      $this->assertEqual($properties[$langcode]['name'][0], $field->value, format_string('%entity_type: The entity name has been correctly stored for language %langcode.', $args));
+      $this->assertEqual($properties[$langcode]['name'][0], $field->value, SafeMarkup::format('%entity_type: The entity name has been correctly stored for language %langcode.', $args));
       $field_langcode = ($langcode == $entity->language()->getId()) ? $default_langcode : $langcode;
-      $this->assertEqual($field_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expected langcode  %langcode.', $args));
-      $this->assertEqual($properties[$langcode]['user_id'][0], $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored for language %langcode.', $args));
+      $this->assertEqual($field_langcode, $field->getLangcode(), SafeMarkup::format('%entity_type: The field object has the expected langcode  %langcode.', $args));
+      $this->assertEqual($properties[$langcode]['user_id'][0], $entity->getTranslation($langcode)->get('user_id')->target_id, SafeMarkup::format('%entity_type: The entity author has been correctly stored for language %langcode.', $args));
     }
 
     // Test query conditions (cache is reset at each call).
@@ -244,24 +245,24 @@ protected function doTestMultilingualProperties($entity_type) {
     ))->save();
 
     $entities = entity_load_multiple($entity_type);
-    $this->assertEqual(count($entities), 3, format_string('%entity_type: Three entities were created.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entities), 3, SafeMarkup::format('%entity_type: Three entities were created.', array('%entity_type' => $entity_type)));
     $entities = entity_load_multiple($entity_type, array($translated_id));
-    $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by id.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entities), 1, SafeMarkup::format('%entity_type: One entity correctly loaded by id.', array('%entity_type' => $entity_type)));
     $entities = entity_load_multiple_by_properties($entity_type, array('name' => $name));
-    $this->assertEqual(count($entities), 2, format_string('%entity_type: Two entities correctly loaded by name.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entities), 2, SafeMarkup::format('%entity_type: Two entities correctly loaded by name.', array('%entity_type' => $entity_type)));
     // @todo The default language condition should go away in favor of an
     // explicit parameter.
     $entities = entity_load_multiple_by_properties($entity_type, array('name' => $properties[$langcode]['name'][0], $default_langcode_key => 0));
-    $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by name translation.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entities), 1, SafeMarkup::format('%entity_type: One entity correctly loaded by name translation.', array('%entity_type' => $entity_type)));
     $entities = entity_load_multiple_by_properties($entity_type, array($langcode_key => $default_langcode, 'name' => $name));
-    $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by name and language.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entities), 1, SafeMarkup::format('%entity_type: One entity correctly loaded by name and language.', array('%entity_type' => $entity_type)));
 
     $entities = entity_load_multiple_by_properties($entity_type, array($langcode_key => $langcode, 'name' => $properties[$langcode]['name'][0]));
-    $this->assertEqual(count($entities), 0, format_string('%entity_type: No entity loaded by name translation specifying the translation language.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entities), 0, SafeMarkup::format('%entity_type: No entity loaded by name translation specifying the translation language.', array('%entity_type' => $entity_type)));
     $entities = entity_load_multiple_by_properties($entity_type, array($langcode_key => $langcode, 'name' => $properties[$langcode]['name'][0], $default_langcode_key => 0));
-    $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity loaded by name translation and language specifying to look for translations.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entities), 1, SafeMarkup::format('%entity_type: One entity loaded by name translation and language specifying to look for translations.', array('%entity_type' => $entity_type)));
     $entities = entity_load_multiple_by_properties($entity_type, array('user_id' => $properties[$langcode]['user_id'][0], $default_langcode_key => NULL));
-    $this->assertEqual(count($entities), 2, format_string('%entity_type: Two entities loaded by uid without caring about property translatability.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($entities), 2, SafeMarkup::format('%entity_type: Two entities loaded by uid without caring about property translatability.', array('%entity_type' => $entity_type)));
 
     // Test property conditions and orders with multiple languages in the same
     // query.
@@ -273,7 +274,7 @@ protected function doTestMultilingualProperties($entity_type) {
       ->condition($group)
       ->condition('name', $properties[$langcode]['name'][0], '=', $langcode)
       ->execute();
-    $this->assertEqual(count($result), 1, format_string('%entity_type: One entity loaded by name and uid using different language meta conditions.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($result), 1, SafeMarkup::format('%entity_type: One entity loaded by name and uid using different language meta conditions.', array('%entity_type' => $entity_type)));
 
     // Test mixed property and field conditions.
     $entity = entity_load($entity_type, reset($result), TRUE);
@@ -292,7 +293,7 @@ protected function doTestMultilingualProperties($entity_type) {
       ->condition($default_langcode_group)
       ->condition($langcode_group)
       ->execute();
-    $this->assertEqual(count($result), 1, format_string('%entity_type: One entity loaded by name, uid and field value using different language meta conditions.', array('%entity_type' => $entity_type)));
+    $this->assertEqual(count($result), 1, SafeMarkup::format('%entity_type: One entity loaded by name, uid and field value using different language meta conditions.', array('%entity_type' => $entity_type)));
   }
 
   /**
@@ -420,7 +421,7 @@ protected function doTestEntityTranslationAPI($entity_type) {
     $translation = $entity->getTranslation($langcode2);
     $entity->removeTranslation($langcode2);
     foreach (array('get', 'set', '__get', '__set', 'createDuplicate') as $method) {
-      $message = format_string('The @method method raises an exception when trying to manipulate a removed translation.', array('@method' => $method));
+      $message = SafeMarkup::format('The @method method raises an exception when trying to manipulate a removed translation.', array('@method' => $method));
       try {
         $translation->{$method}('name', $this->randomMachineName());
         $this->fail($message);
@@ -442,7 +443,7 @@ protected function doTestEntityTranslationAPI($entity_type) {
     // Check that removing an invalid translation causes an exception to be
     // thrown.
     foreach (array($default_langcode, LanguageInterface::LANGCODE_DEFAULT, $this->randomMachineName()) as $invalid_langcode) {
-      $message = format_string('Removing an invalid translation (@langcode) causes an exception to be thrown.', array('@langcode' => $invalid_langcode));
+      $message = SafeMarkup::format('Removing an invalid translation (@langcode) causes an exception to be thrown.', array('@langcode' => $invalid_langcode));
       try {
         $entity->removeTranslation($invalid_langcode);
         $this->fail($message);
@@ -644,7 +645,7 @@ function testFieldDefinitions() {
     foreach ($translatable_fields as $name => $translatable) {
       $this->state->set('entity_test.field_definitions.translatable', array($name => $translatable));
       $this->entityManager->clearCachedFieldDefinitions();
-      $message = format_string('Field %field cannot be translatable.', array('%field' => $name));
+      $message = SafeMarkup::format('Field %field cannot be translatable.', array('%field' => $name));
 
       try {
         $this->entityManager->getBaseFieldDefinitions($entity_type);
@@ -738,7 +739,7 @@ function testEntityAdapter() {
     foreach ($langcodes as $langcode) {
       $adapter = $entity->getTranslation($langcode)->getTypedData();
       $name = $adapter->get('name')->value;
-      $this->assertEqual($name, $values[$langcode]['name'], String::format('Name correctly retrieved from "@langcode" adapter', array('@langcode' => $langcode)));
+      $this->assertEqual($name, $values[$langcode]['name'], SafeMarkup::format('Name correctly retrieved from "@langcode" adapter', array('@langcode' => $langcode)));
     }
   }
 
diff --git a/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php b/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php
index d2d6fed..652443a 100644
--- a/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php
+++ b/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Extension;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Drupal\simpletest\KernelTestBase;
 use \Drupal\Core\Extension\ModuleUninstallValidatorException;
@@ -86,7 +87,7 @@ protected function assertModuleList(Array $expected_values, $condition) {
     $expected_values = array_values(array_unique($expected_values));
     $enabled_modules = array_keys($this->container->get('module_handler')->getModuleList());
     $enabled_modules = sort($enabled_modules);
-    $this->assertEqual($expected_values, $enabled_modules, format_string('@condition: extension handler returns correct results', array('@condition' => $condition)));
+    $this->assertEqual($expected_values, $enabled_modules, SafeMarkup::format('@condition: extension handler returns correct results', array('@condition' => $condition)));
   }
 
   /**
diff --git a/core/modules/system/src/Tests/File/DirectoryTest.php b/core/modules/system/src/Tests/File/DirectoryTest.php
index 0822063..148ab51 100644
--- a/core/modules/system/src/Tests/File/DirectoryTest.php
+++ b/core/modules/system/src/Tests/File/DirectoryTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\system\Tests\File;
+use Drupal\Component\Utility\SafeMarkup;
 
 use Drupal\Component\PhpStorage\FileStorage;
 
@@ -109,14 +110,14 @@ function testFileCreateNewFilepath() {
     $directory = 'core/misc';
     $original = $directory . '/' . $basename;
     $path = file_create_filename($basename, $directory);
-    $this->assertEqual($path, $original, format_string('New filepath %new equals %original.', array('%new' => $path, '%original' => $original)), 'File');
+    $this->assertEqual($path, $original, SafeMarkup::format('New filepath %new equals %original.', array('%new' => $path, '%original' => $original)), 'File');
 
     // Then we test against a file that already exists within that directory.
     $basename = 'druplicon.png';
     $original = $directory . '/' . $basename;
     $expected = $directory . '/druplicon_0.png';
     $path = file_create_filename($basename, $directory);
-    $this->assertEqual($path, $expected, format_string('Creating a new filepath from %original equals %new (expected %expected).', array('%new' => $path, '%original' => $original, '%expected' => $expected)), 'File');
+    $this->assertEqual($path, $expected, SafeMarkup::format('Creating a new filepath from %original equals %new (expected %expected).', array('%new' => $path, '%original' => $original, '%expected' => $expected)), 'File');
 
     // @TODO: Finally we copy a file into a directory several times, to ensure a properly iterating filename suffix.
   }
diff --git a/core/modules/system/src/Tests/File/HtaccessUnitTest.php b/core/modules/system/src/Tests/File/HtaccessUnitTest.php
index 7d71a33..d998282 100644
--- a/core/modules/system/src/Tests/File/HtaccessUnitTest.php
+++ b/core/modules/system/src/Tests/File/HtaccessUnitTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\File;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\simpletest\KernelTestBase;
 
@@ -89,7 +90,7 @@ function testHtaccessSave() {
    */
   protected function assertFilePermissions($uri, $expected) {
     $actual = fileperms($uri) & 0777;
-    return $this->assertIdentical($actual, $expected, String::format('@uri file permissions @actual are identical to @expected.', array(
+    return $this->assertIdentical($actual, $expected, SafeMarkup::format('@uri file permissions @actual are identical to @expected.', array(
       '@uri' => $uri,
       '@actual' => 0 . decoct($actual),
       '@expected' => 0 . decoct($expected),
diff --git a/core/modules/system/src/Tests/File/MimeTypeTest.php b/core/modules/system/src/Tests/File/MimeTypeTest.php
index f09b60d..8cf22cd 100644
--- a/core/modules/system/src/Tests/File/MimeTypeTest.php
+++ b/core/modules/system/src/Tests/File/MimeTypeTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\system\Tests\File;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests filename mimetype detection.
@@ -49,11 +50,11 @@ public function testFileMimeTypeDetection() {
     foreach ($test_case as $input => $expected) {
       // Test stream [URI].
       $output = $guesser->guess($prefix . $input);
-      $this->assertIdentical($output, $expected, format_string('Mimetype for %input is %output (expected: %expected).', array('%input' => $input, '%output' => $output, '%expected' => $expected)));
+      $this->assertIdentical($output, $expected, SafeMarkup::format('Mimetype for %input is %output (expected: %expected).', array('%input' => $input, '%output' => $output, '%expected' => $expected)));
 
       // Test normal path equivalent
       $output = $guesser->guess($input);
-      $this->assertIdentical($output, $expected, format_string('Mimetype (using default mappings) for %input is %output (expected: %expected).', array('%input' => $input, '%output' => $output, '%expected' => $expected)));
+      $this->assertIdentical($output, $expected, SafeMarkup::format('Mimetype (using default mappings) for %input is %output (expected: %expected).', array('%input' => $input, '%output' => $output, '%expected' => $expected)));
     }
 
     // Now test the extension gusser by passing in a custom mapping.
@@ -88,7 +89,7 @@ public function testFileMimeTypeDetection() {
 
     foreach ($test_case as $input => $expected) {
       $output = $extension_guesser->guess($input);
-      $this->assertIdentical($output, $expected, format_string('Mimetype (using passed-in mappings) for %input is %output (expected: %expected).', array('%input' => $input, '%output' => $output, '%expected' => $expected)));
+      $this->assertIdentical($output, $expected, SafeMarkup::format('Mimetype (using passed-in mappings) for %input is %output (expected: %expected).', array('%input' => $input, '%output' => $output, '%expected' => $expected)));
     }
   }
 }
diff --git a/core/modules/system/src/Tests/File/NameMungingTest.php b/core/modules/system/src/Tests/File/NameMungingTest.php
index 06f44c8..cfd6d33 100644
--- a/core/modules/system/src/Tests/File/NameMungingTest.php
+++ b/core/modules/system/src/Tests/File/NameMungingTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\system\Tests\File;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Tests filename munging and unmunging.
@@ -45,7 +46,7 @@ function testMunging() {
     $munged_name = file_munge_filename($this->name, '', TRUE);
     $messages = drupal_get_messages();
     $this->assertTrue(in_array(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $munged_name)), $messages['status']), 'Alert properly set when a file is renamed.');
-    $this->assertNotEqual($munged_name, $this->name, format_string('The new filename (%munged) has been modified from the original (%original)', array('%munged' => $munged_name, '%original' => $this->name)));
+    $this->assertNotEqual($munged_name, $this->name, SafeMarkup::format('The new filename (%munged) has been modified from the original (%original)', array('%munged' => $munged_name, '%original' => $this->name)));
   }
 
   /**
@@ -64,7 +65,7 @@ function testMungeNullByte() {
   function testMungeIgnoreInsecure() {
     $this->config('system.file')->set('allow_insecure_uploads', 1)->save();
     $munged_name = file_munge_filename($this->name, '');
-    $this->assertIdentical($munged_name, $this->name, format_string('The original filename (%original) matches the munged filename (%munged) when insecure uploads are enabled.', array('%munged' => $munged_name, '%original' => $this->name)));
+    $this->assertIdentical($munged_name, $this->name, SafeMarkup::format('The original filename (%original) matches the munged filename (%munged) when insecure uploads are enabled.', array('%munged' => $munged_name, '%original' => $this->name)));
   }
 
   /**
@@ -74,10 +75,10 @@ function testMungeIgnoreWhitelisted() {
     // Declare our extension as whitelisted. The declared extensions should
     // be case insensitive so test using one with a different case.
     $munged_name = file_munge_filename($this->name_with_uc_ext, $this->bad_extension);
-    $this->assertIdentical($munged_name, $this->name_with_uc_ext, format_string('The new filename (%munged) matches the original (%original) once the extension has been whitelisted.', array('%munged' => $munged_name, '%original' => $this->name_with_uc_ext)));
+    $this->assertIdentical($munged_name, $this->name_with_uc_ext, SafeMarkup::format('The new filename (%munged) matches the original (%original) once the extension has been whitelisted.', array('%munged' => $munged_name, '%original' => $this->name_with_uc_ext)));
     // The allowed extensions should also be normalized.
     $munged_name = file_munge_filename($this->name, strtoupper($this->bad_extension));
-    $this->assertIdentical($munged_name, $this->name, format_string('The new filename (%munged) matches the original (%original) also when the whitelisted extension is in uppercase.', array('%munged' => $munged_name, '%original' => $this->name)));
+    $this->assertIdentical($munged_name, $this->name, SafeMarkup::format('The new filename (%munged) matches the original (%original) also when the whitelisted extension is in uppercase.', array('%munged' => $munged_name, '%original' => $this->name)));
   }
 
   /**
@@ -86,6 +87,6 @@ function testMungeIgnoreWhitelisted() {
   function testUnMunge() {
     $munged_name = file_munge_filename($this->name, '', FALSE);
     $unmunged_name = file_unmunge_filename($munged_name);
-    $this->assertIdentical($unmunged_name, $this->name, format_string('The unmunged (%unmunged) filename matches the original (%original)', array('%unmunged' => $unmunged_name, '%original' => $this->name)));
+    $this->assertIdentical($unmunged_name, $this->name, SafeMarkup::format('The unmunged (%unmunged) filename matches the original (%original)', array('%unmunged' => $unmunged_name, '%original' => $this->name)));
   }
 }
diff --git a/core/modules/system/src/Tests/Form/CheckboxTest.php b/core/modules/system/src/Tests/Form/CheckboxTest.php
index da53a79..eb819fb 100644
--- a/core/modules/system/src/Tests/Form/CheckboxTest.php
+++ b/core/modules/system/src/Tests/Form/CheckboxTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Form;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -53,7 +54,7 @@ function testFormCheckbox() {
           $checked = ($default_value === '1foobar');
         }
         $checked_in_html = strpos($form, 'checked') !== FALSE;
-        $message = format_string('#default_value is %default_value #return_value is %return_value.', array('%default_value' => var_export($default_value, TRUE), '%return_value' => var_export($return_value, TRUE)));
+        $message = SafeMarkup::format('#default_value is %default_value #return_value is %return_value.', array('%default_value' => var_export($default_value, TRUE), '%return_value' => var_export($return_value, TRUE)));
         $this->assertIdentical($checked, $checked_in_html, $message);
       }
     }
@@ -75,7 +76,7 @@ function testFormCheckbox() {
     foreach ($checkboxes as $checkbox) {
       $checked = isset($checkbox['checked']);
       $name = (string) $checkbox['name'];
-      $this->assertIdentical($checked, $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', array('%name' => $name)));
+      $this->assertIdentical($checked, $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', SafeMarkup::format('Checkbox %name correctly checked', array('%name' => $name)));
     }
     $edit = array('checkbox_off[0]' => '0');
     $this->drupalPostForm('form-test/checkboxes-zero/0', $edit, 'Save');
@@ -83,7 +84,7 @@ function testFormCheckbox() {
     foreach ($checkboxes as $checkbox) {
       $checked = isset($checkbox['checked']);
       $name = (string) $checkbox['name'];
-      $this->assertIdentical($checked, $name == 'checkbox_off[0]' || $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', array('%name' => $name)));
+      $this->assertIdentical($checked, $name == 'checkbox_off[0]' || $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', SafeMarkup::format('Checkbox %name correctly checked', array('%name' => $name)));
     }
   }
 }
diff --git a/core/modules/system/src/Tests/Form/ConfirmFormTest.php b/core/modules/system/src/Tests/Form/ConfirmFormTest.php
index 9521176..edec0c0 100644
--- a/core/modules/system/src/Tests/Form/ConfirmFormTest.php
+++ b/core/modules/system/src/Tests/Form/ConfirmFormTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Form;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Url;
 use Drupal\simpletest\WebTestBase;
@@ -79,7 +80,7 @@ public function testConfirmFormWithExternalDestination() {
    */
   public function assertCancelLinkUrl(Url $url, $message = '', $group = 'Other') {
     $links = $this->xpath('//a[@href=:url]', [':url' => $url->toString()]);
-    $message = ($message ? $message : String::format('Cancel link with url %url found.', ['%url' => $url->toString()]));
+    $message = ($message ? $message : SafeMarkup::format('Cancel link with url %url found.', ['%url' => $url->toString()]));
     return $this->assertTrue(isset($links[0]), $message, $group);
   }
 
diff --git a/core/modules/system/src/Tests/Form/ElementTest.php b/core/modules/system/src/Tests/Form/ElementTest.php
index 9fa7eca..9b389ed 100644
--- a/core/modules/system/src/Tests/Form/ElementTest.php
+++ b/core/modules/system/src/Tests/Form/ElementTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Form;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -35,7 +36,7 @@ function testPlaceHolderText() {
         ':id' => 'edit-' . $type,
         ':expected' => $expected,
       ));
-      $this->assertTrue(!empty($element), format_string('Placeholder text placed in @type.', array('@type' => $type)));
+      $this->assertTrue(!empty($element), SafeMarkup::format('Placeholder text placed in @type.', array('@type' => $type)));
     }
 
     // Test to make sure textarea has the proper placeholder text.
@@ -81,7 +82,7 @@ function testOptions() {
         ':id' => 'edit-' . $type . '-foo',
         ':class' => 'description',
       ));
-      $this->assertTrue(count($elements), format_string('Custom %type option description found.', array(
+      $this->assertTrue(count($elements), SafeMarkup::format('Custom %type option description found.', array(
         '%type' => $type,
       )));
     }
@@ -97,8 +98,8 @@ function testWrapperIds() {
     foreach (array('checkboxes', 'radios') as $type) {
       $element_ids = $this->xpath('//div[@id=:id]', array(':id' => 'edit-' . $type));
       $wrapper_ids = $this->xpath('//fieldset[@id=:id]', array(':id' => 'edit-' . $type . '--wrapper'));
-      $this->assertTrue(count($element_ids) == 1, format_string('A single element id found for type %type', array('%type' => $type)));
-      $this->assertTrue(count($wrapper_ids) == 1, format_string('A single wrapper id found for type %type', array('%type' => $type)));
+      $this->assertTrue(count($element_ids) == 1, SafeMarkup::format('A single element id found for type %type', array('%type' => $type)));
+      $this->assertTrue(count($wrapper_ids) == 1, SafeMarkup::format('A single wrapper id found for type %type', array('%type' => $type)));
     }
   }
 
diff --git a/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php b/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php
index 8d6cb65..5b3170c 100644
--- a/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php
+++ b/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Form;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Form\FormState;
 use Drupal\simpletest\WebTestBase;
 use Drupal\Core\Form\FormStateInterface;
@@ -39,7 +40,7 @@ function testMultipleTrue() {
 
     $rows = array('row1', 'row2', 'row3');
     foreach ($rows as $row) {
-      $this->assertFieldByXPath('//input[@type="checkbox"]', $row, format_string('Checkbox for value @row.', array('@row' => $row)));
+      $this->assertFieldByXPath('//input[@type="checkbox"]', $row, SafeMarkup::format('Checkbox for value @row.', array('@row' => $row)));
     }
   }
 
@@ -56,7 +57,7 @@ function testMultipleFalse() {
 
     $rows = array('row1', 'row2', 'row3');
     foreach ($rows as $row) {
-      $this->assertFieldByXPath('//input[@type="radio"]', $row, format_string('Radio button for value @row.', array('@row' => $row)));
+      $this->assertFieldByXPath('//input[@type="radio"]', $row, SafeMarkup::format('Radio button for value @row.', array('@row' => $row)));
     }
   }
 
@@ -78,7 +79,7 @@ function testTableselectColSpan() {
     // radio, one cell in the first column, one cell in the second column,
     // and two cells in the third column which has colspan 2.
     for ( $i = 0; $i <= 1; $i++) {
-      $this->assertEqual(count($table_body[0]->tr[$i]->td), 5, format_string('There are five cells in row @row.', array('@row' => $i)));
+      $this->assertEqual(count($table_body[0]->tr[$i]->td), 5, SafeMarkup::format('There are five cells in row @row.', array('@row' => $i)));
     }
     // The third row should have 3 cells, one for the radio, one spanning the
     // first and second column, and a third in column 3 (which has colspan 3).
diff --git a/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php b/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php
index a69da46..d4b5e44 100644
--- a/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php
+++ b/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Form;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\simpletest\WebTestBase;
 use Drupal\Component\Serialization\Json;
@@ -74,6 +75,6 @@ function testDefaultTab() {
    */
   function testDefaultTabCleaned() {
     $values = Json::decode($this->drupalPostForm('form_test/form-state-values-clean', [], t('Submit')));
-    $this->assertFalse(isset($values['vertical_tabs__active_tab']), String::format('%element was removed.', ['%element' => 'vertical_tabs__active_tab']));
+    $this->assertFalse(isset($values['vertical_tabs__active_tab']), SafeMarkup::format('%element was removed.', ['%element' => 'vertical_tabs__active_tab']));
   }
 }
diff --git a/core/modules/system/src/Tests/Form/FormTest.php b/core/modules/system/src/Tests/Form/FormTest.php
index 0197e8a..4cd985c 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\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Form\FormState;
 use Drupal\Core\Render\Element;
@@ -193,7 +194,7 @@ function testRequiredCheckboxesRadio() {
       $expected_key = array_search($error[0], $expected);
       // If the error message is not one of the expected messages, fail.
       if ($expected_key === FALSE) {
-        $this->fail(format_string("Unexpected error message: @error", array('@error' => $error[0])));
+        $this->fail(SafeMarkup::format("Unexpected error message: @error", array('@error' => $error[0])));
       }
       // Remove the expected message from the list once it is found.
       else {
@@ -203,7 +204,7 @@ function testRequiredCheckboxesRadio() {
 
     // Fail if any expected messages were not found.
     foreach ($expected as $not_found) {
-      $this->fail(format_string("Found error message: @error", array('@error' => $not_found)));
+      $this->fail(SafeMarkup::format("Found error message: @error", array('@error' => $not_found)));
     }
 
     // Verify that input elements are still empty.
@@ -285,7 +286,7 @@ function testCheckboxProcessing() {
       'zero_checkbox_off' => '',
     );
     foreach ($expected_values as $widget => $expected_value) {
-      $this->assertEqual($values[$widget], $expected_value, format_string('Checkbox %widget returns expected value (expected: %expected, got: %value)', array(
+      $this->assertEqual($values[$widget], $expected_value, SafeMarkup::format('Checkbox %widget returns expected value (expected: %expected, got: %value)', array(
         '%widget' => var_export($widget, TRUE),
         '%expected' => var_export($expected_value, TRUE),
         '%value' => var_export($values[$widget], TRUE),
@@ -359,7 +360,7 @@ function testSelect() {
       'multiple_no_default_required' => array('three' => 'three'),
     );
     foreach ($expected as $key => $value) {
-      $this->assertIdentical($values[$key], $value, format_string('@name: @actual is equal to @expected.', array(
+      $this->assertIdentical($values[$key], $value, SafeMarkup::format('@name: @actual is equal to @expected.', array(
         '@name' => $key,
         '@actual' => var_export($values[$key], TRUE),
         '@expected' => var_export($value, TRUE),
@@ -430,10 +431,10 @@ function testNumber() {
           // Check if the error exists on the page, if the current message ID is
           // expected. Otherwise ensure that the error message is not present.
           if ($id === $error) {
-            $this->assertRaw(format_string($message, $placeholders));
+            $this->assertRaw(SafeMarkup::format($message, $placeholders));
           }
           else {
-            $this->assertNoRaw(format_string($message, $placeholders));
+            $this->assertNoRaw(SafeMarkup::format($message, $placeholders));
           }
         }
       }
@@ -534,7 +535,7 @@ function testDisabledElements() {
     // the disabled container.
     $actual_count = count($disabled_elements);
     $expected_count = 41;
-    $this->assertEqual($actual_count, $expected_count, String::format('Found @actual elements with disabled property (expected @expected).', array(
+    $this->assertEqual($actual_count, $expected_count, SafeMarkup::format('Found @actual elements with disabled property (expected @expected).', array(
       '@actual' => count($disabled_elements),
       '@expected' => $expected_count,
     )));
@@ -566,7 +567,7 @@ function assertFormValuesDefault($values, $form) {
           // Checkboxes values are not filtered out.
           $values[$key] = array_filter($values[$key]);
         }
-        $this->assertIdentical($expected_value, $values[$key], format_string('Default value for %type: expected %expected, returned %returned.', array('%type' => $key, '%expected' => var_export($expected_value, TRUE), '%returned' => var_export($values[$key], TRUE))));
+        $this->assertIdentical($expected_value, $values[$key], SafeMarkup::format('Default value for %type: expected %expected, returned %returned.', array('%type' => $key, '%expected' => var_export($expected_value, TRUE), '%returned' => var_export($values[$key], TRUE))));
       }
 
       // Recurse children.
@@ -620,7 +621,7 @@ function testDisabledMarkup() {
         ':div-class' => $class,
         ':value' => isset($item['#value']) ? $item['#value'] : '',
       ));
-      $this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', array('%type' => $item['#type'])));
+      $this->assertTrue(isset($element[0]), SafeMarkup::format('Disabled form element class found for #type %type.', array('%type' => $item['#type'])));
     }
 
     // Verify special element #type text-format.
@@ -628,12 +629,12 @@ function testDisabledMarkup() {
       ':name' => 'text_format[value]',
       ':div-class' => 'form-disabled',
     ));
-    $this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', array('%type' => 'text_format[value]')));
+    $this->assertTrue(isset($element[0]), SafeMarkup::format('Disabled form element class found for #type %type.', array('%type' => 'text_format[value]')));
     $element = $this->xpath('//div[contains(@class, :div-class)]/descendant::select[@name=:name]', array(
       ':name' => 'text_format[format]',
       ':div-class' => 'form-disabled',
     ));
-    $this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', array('%type' => 'text_format[format]')));
+    $this->assertTrue(isset($element[0]), SafeMarkup::format('Disabled form element class found for #type %type.', array('%type' => 'text_format[format]')));
   }
 
   /**
@@ -661,7 +662,7 @@ function testRequiredAttribute() {
         ':id' => 'edit-' . $type,
         ':expected' => $expected,
       ));
-      $this->assertTrue(!empty($element), format_string('The @type has the proper required attribute.', array('@type' => $type)));
+      $this->assertTrue(!empty($element), SafeMarkup::format('The @type has the proper required attribute.', array('@type' => $type)));
     }
 
     // Test to make sure textarea has the proper required attribute.
diff --git a/core/modules/system/src/Tests/Form/LanguageSelectElementTest.php b/core/modules/system/src/Tests/Form/LanguageSelectElementTest.php
index 410d320..6f9611c 100644
--- a/core/modules/system/src/Tests/Form/LanguageSelectElementTest.php
+++ b/core/modules/system/src/Tests/Form/LanguageSelectElementTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\system\Tests\Form;
 
 use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\simpletest\WebTestBase;
@@ -53,7 +54,7 @@ function testLanguageSelectElementOptions() {
         'edit-languages-config-and-locked' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_LOCKED
     );
     foreach ($ids as $id => $flags) {
-      $this->assertField($id, format_string('The @id field was found on the page.', array('@id' => $id)));
+      $this->assertField($id, SafeMarkup::format('The @id field was found on the page.', array('@id' => $id)));
       $options = array();
       /* @var $language_manager \Drupal\Core\Language\LanguageManagerInterface */
       $language_manager = $this->container->get('language_manager');
@@ -64,7 +65,7 @@ function testLanguageSelectElementOptions() {
     }
 
     // Test that the #options were not altered by #languages.
-    $this->assertField('edit-language-custom-options', format_string('The @id field was found on the page.', array('@id' => 'edit-language-custom-options')));
+    $this->assertField('edit-language-custom-options', SafeMarkup::format('The @id field was found on the page.', array('@id' => 'edit-language-custom-options')));
     $this->_testLanguageSelectElementOptions('edit-language-custom-options', array('opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option'));
   }
 
@@ -81,7 +82,7 @@ function testHiddenLanguageSelectElement() {
     // Check that the language fields were rendered on the page.
     $ids = array('edit-languages-all', 'edit-languages-configurable', 'edit-languages-locked', 'edit-languages-config-and-locked');
     foreach ($ids as $id) {
-      $this->assertNoField($id, format_string('The @id field was not found on the page.', array('@id' => $id)));
+      $this->assertNoField($id, SafeMarkup::format('The @id field was not found on the page.', array('@id' => $id)));
     }
 
     // Check that the submitted values were the default values of the language
@@ -116,6 +117,6 @@ protected function _testLanguageSelectElementOptions($id, $options) {
       $this->assertEqual((string) $option, $option_title);
       next($options);
     }
-    $this->assertEqual($count, count($options), format_string('The number of languages and the number of options shown by the language element are the same: @languages languages, @number options', array('@languages' => count($options), '@number' => $count)));
+    $this->assertEqual($count, count($options), SafeMarkup::format('The number of languages and the number of options shown by the language element are the same: @languages languages, @number options', array('@languages' => count($options), '@number' => $count)));
   }
 }
diff --git a/core/modules/system/src/Tests/Form/ProgrammaticTest.php b/core/modules/system/src/Tests/Form/ProgrammaticTest.php
index ef8130c..1b8d1fa 100644
--- a/core/modules/system/src/Tests/Form/ProgrammaticTest.php
+++ b/core/modules/system/src/Tests/Form/ProgrammaticTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Form;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Form\FormState;
 use Drupal\simpletest\WebTestBase;
 
@@ -82,14 +83,14 @@ private function submitForm($values, $valid_input) {
       '%values' => print_r($values, TRUE),
       '%errors' => $valid_form ? t('None') : implode(' ', $errors),
     );
-    $this->assertTrue($valid_input == $valid_form, format_string('Input values: %values<br />Validation handler errors: %errors', $args));
+    $this->assertTrue($valid_input == $valid_form, SafeMarkup::format('Input values: %values<br />Validation handler errors: %errors', $args));
 
     // We check submitted values only if we have a valid input.
     if ($valid_input) {
       // Fetching the values that were set in the submission handler.
       $stored_values = $form_state->get('programmatic_form_submit');
       foreach ($values as $key => $value) {
-        $this->assertEqual($stored_values[$key], $value, format_string('Submission handler correctly executed: %stored_key is %stored_value', array('%stored_key' => $key, '%stored_value' => print_r($value, TRUE))));
+        $this->assertEqual($stored_values[$key], $value, SafeMarkup::format('Submission handler correctly executed: %stored_key is %stored_value', array('%stored_key' => $key, '%stored_value' => print_r($value, TRUE))));
       }
     }
   }
diff --git a/core/modules/system/src/Tests/Form/StateValuesCleanTest.php b/core/modules/system/src/Tests/Form/StateValuesCleanTest.php
index f07ae8c..72cea57 100644
--- a/core/modules/system/src/Tests/Form/StateValuesCleanTest.php
+++ b/core/modules/system/src/Tests/Form/StateValuesCleanTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\system\Tests\Form;
 
 use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\simpletest\WebTestBase;
 
@@ -39,19 +40,19 @@ function testFormStateValuesClean() {
     );
 
     // Verify that all internal Form API elements were removed.
-    $this->assertFalse(isset($values['form_id']), format_string('%element was removed.', array('%element' => 'form_id')));
-    $this->assertFalse(isset($values['form_token']), format_string('%element was removed.', array('%element' => 'form_token')));
-    $this->assertFalse(isset($values['form_build_id']), format_string('%element was removed.', array('%element' => 'form_build_id')));
-    $this->assertFalse(isset($values['op']), format_string('%element was removed.', array('%element' => 'op')));
+    $this->assertFalse(isset($values['form_id']), SafeMarkup::format('%element was removed.', array('%element' => 'form_id')));
+    $this->assertFalse(isset($values['form_token']), SafeMarkup::format('%element was removed.', array('%element' => 'form_token')));
+    $this->assertFalse(isset($values['form_build_id']), SafeMarkup::format('%element was removed.', array('%element' => 'form_build_id')));
+    $this->assertFalse(isset($values['op']), SafeMarkup::format('%element was removed.', array('%element' => 'op')));
 
     // Verify that all buttons were removed.
-    $this->assertFalse(isset($values['foo']), format_string('%element was removed.', array('%element' => 'foo')));
-    $this->assertFalse(isset($values['bar']), format_string('%element was removed.', array('%element' => 'bar')));
-    $this->assertFalse(isset($values['baz']['foo']), format_string('%element was removed.', array('%element' => 'foo')));
-    $this->assertFalse(isset($values['baz']['baz']), format_string('%element was removed.', array('%element' => 'baz')));
+    $this->assertFalse(isset($values['foo']), SafeMarkup::format('%element was removed.', array('%element' => 'foo')));
+    $this->assertFalse(isset($values['bar']), SafeMarkup::format('%element was removed.', array('%element' => 'bar')));
+    $this->assertFalse(isset($values['baz']['foo']), SafeMarkup::format('%element was removed.', array('%element' => 'foo')));
+    $this->assertFalse(isset($values['baz']['baz']), SafeMarkup::format('%element was removed.', array('%element' => 'baz')));
 
     // Verify values manually added for cleaning were removed.
-    $this->assertFalse(isset($values['wine']), String::format('%element was removed.', ['%element' => 'wine']));
+    $this->assertFalse(isset($values['wine']), SafeMarkup::format('%element was removed.', ['%element' => 'wine']));
 
     // Verify that nested form value still exists.
     $this->assertTrue(isset($values['baz']['beer']), 'Nested form value still exists.');
diff --git a/core/modules/system/src/Tests/Form/ValidationTest.php b/core/modules/system/src/Tests/Form/ValidationTest.php
index 7b6c9e8..9302a0e 100644
--- a/core/modules/system/src/Tests/Form/ValidationTest.php
+++ b/core/modules/system/src/Tests/Form/ValidationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Form;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Render\Element;
 use Drupal\simpletest\WebTestBase;
 
@@ -95,7 +96,7 @@ function testValidateLimitErrors() {
         ':id' => 'edit-' . $type,
         ':expected' => $expected,
       ));
-      $this->assertTrue(!empty($element), format_string('The @type button has the proper formnovalidate attribute.', array('@type' => $type)));
+      $this->assertTrue(!empty($element), SafeMarkup::format('The @type button has the proper formnovalidate attribute.', array('@type' => $type)));
     }
     // The button with full server-side validation should not have the
     // 'formnovalidate' attribute.
diff --git a/core/modules/system/src/Tests/Image/ToolkitGdTest.php b/core/modules/system/src/Tests/Image/ToolkitGdTest.php
index f4face0..5222c53 100644
--- a/core/modules/system/src/Tests/Image/ToolkitGdTest.php
+++ b/core/modules/system/src/Tests/Image/ToolkitGdTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Image;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Image\ImageInterface;
 use \Drupal\simpletest\KernelTestBase;
 use Drupal\Component\Utility\String;
@@ -262,14 +263,14 @@ function testManipulations() {
         $image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/' . $file);
         $toolkit = $image->getToolkit();
         if (!$image->isValid()) {
-          $this->fail(String::format('Could not load image %file.', array('%file' => $file)));
+          $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file)));
           continue 2;
         }
         $image_original_type = $image->getToolkit()->getType();
 
         // All images should be converted to truecolor when loaded.
         $image_truecolor = imageistruecolor($toolkit->getResource());
-        $this->assertTrue($image_truecolor, String::format('Image %file after load is a truecolor image.', array('%file' => $file)));
+        $this->assertTrue($image_truecolor, SafeMarkup::format('Image %file after load is a truecolor image.', array('%file' => $file)));
 
         if ($image->getToolkit()->getType() == IMAGETYPE_GIF) {
           if ($op == 'desaturate') {
@@ -312,8 +313,8 @@ function testManipulations() {
         $file_path = $directory . '/' . $op . image_type_to_extension($image->getToolkit()->getType());
         $image->save($file_path);
 
-        $this->assertTrue($correct_dimensions_real, String::format('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op)));
-        $this->assertTrue($correct_dimensions_object, String::format('Image %file object after %action action is reporting the proper height and width values.', array('%file' => $file, '%action' => $op)));
+        $this->assertTrue($correct_dimensions_real, SafeMarkup::format('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op)));
+        $this->assertTrue($correct_dimensions_object, SafeMarkup::format('Image %file object after %action action is reporting the proper height and width values.', array('%file' => $file, '%action' => $op)));
 
         // JPEG colors will always be messed up due to compression. So we skip
         // these tests if the original or the result is in jpeg format.
@@ -349,7 +350,7 @@ function testManipulations() {
             // conversion. The convert operation cannot handle that correctly.
             if ($image->getToolkit()->getType() == $image_original_type || $corner != $this->transparent) {
               $correct_colors = $this->colorsAreEqual($color, $corner);
-              $this->assertTrue($correct_colors, String::format('Image %file object after %action action has the correct color placement at corner %corner.',
+              $this->assertTrue($correct_colors, SafeMarkup::format('Image %file object after %action action has the correct color placement at corner %corner.',
                 array('%file'   => $file, '%action' => $op, '%corner' => $key)));
             }
           }
@@ -367,25 +368,25 @@ function testManipulations() {
       $image->createNew(50, 20, image_type_to_extension($type, FALSE), '#ffff00');
       $file = 'from_null' . image_type_to_extension($type);
       $file_path = $directory . '/' . $file ;
-      $this->assertEqual(50, $image->getWidth(), String::format('Image file %file has the correct width.', array('%file' => $file)));
-      $this->assertEqual(20, $image->getHeight(), String::format('Image file %file has the correct height.', array('%file' => $file)));
-      $this->assertEqual(image_type_to_mime_type($type), $image->getMimeType(), String::format('Image file %file has the correct MIME type.', array('%file' => $file)));
-      $this->assertTrue($image->save($file_path), String::format('Image %file created anew from a null image was saved.', array('%file' => $file)));
+      $this->assertEqual(50, $image->getWidth(), SafeMarkup::format('Image file %file has the correct width.', array('%file' => $file)));
+      $this->assertEqual(20, $image->getHeight(), SafeMarkup::format('Image file %file has the correct height.', array('%file' => $file)));
+      $this->assertEqual(image_type_to_mime_type($type), $image->getMimeType(), SafeMarkup::format('Image file %file has the correct MIME type.', array('%file' => $file)));
+      $this->assertTrue($image->save($file_path), SafeMarkup::format('Image %file created anew from a null image was saved.', array('%file' => $file)));
 
       // Reload saved image.
       $image_reloaded = $this->imageFactory->get($file_path);
       if (!$image_reloaded->isValid()) {
-        $this->fail(String::format('Could not load image %file.', array('%file' => $file)));
+        $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file)));
         continue;
       }
-      $this->assertEqual(50, $image_reloaded->getWidth(), String::format('Image file %file has the correct width.', array('%file' => $file)));
-      $this->assertEqual(20, $image_reloaded->getHeight(), String::format('Image file %file has the correct height.', array('%file' => $file)));
-      $this->assertEqual(image_type_to_mime_type($type), $image_reloaded->getMimeType(), String::format('Image file %file has the correct MIME type.', array('%file' => $file)));
+      $this->assertEqual(50, $image_reloaded->getWidth(), SafeMarkup::format('Image file %file has the correct width.', array('%file' => $file)));
+      $this->assertEqual(20, $image_reloaded->getHeight(), SafeMarkup::format('Image file %file has the correct height.', array('%file' => $file)));
+      $this->assertEqual(image_type_to_mime_type($type), $image_reloaded->getMimeType(), SafeMarkup::format('Image file %file has the correct MIME type.', array('%file' => $file)));
       if ($image_reloaded->getToolkit()->getType() == IMAGETYPE_GIF) {
-        $this->assertEqual('#ffff00', $image_reloaded->getToolkit()->getTransparentColor(), String::format('Image file %file has the correct transparent color channel set.', array('%file' => $file)));
+        $this->assertEqual('#ffff00', $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has the correct transparent color channel set.', array('%file' => $file)));
       }
       else  {
-        $this->assertEqual(NULL, $image_reloaded->getToolkit()->getTransparentColor(), String::format('Image file %file has no color channel set.', array('%file' => $file)));
+        $this->assertEqual(NULL, $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has no color channel set.', array('%file' => $file)));
       }
     }
 
@@ -420,12 +421,12 @@ function testTransparentColorOutOfRange() {
     $toolkit = $image->getToolkit();
 
     if (!$image->isValid()) {
-      $this->fail(String::format('Could not load image %file.', array('%file' => $file)));
+      $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file)));
     }
     else {
       // All images should be converted to truecolor when loaded.
       $image_truecolor = imageistruecolor($toolkit->getResource());
-      $this->assertTrue($image_truecolor, String::format('Image %file after load is a truecolor image.', array('%file' => $file)));
+      $this->assertTrue($image_truecolor, SafeMarkup::format('Image %file after load is a truecolor image.', array('%file' => $file)));
     }
   }
 
@@ -443,7 +444,7 @@ function testMissingOperation() {
     // Load up a fresh image.
     $image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/' . $file);
     if (!$image->isValid()) {
-      $this->fail(String::format('Could not load image %file.', array('%file' => $file)));
+      $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file)));
     }
 
     // Try perform a missing toolkit operation.
diff --git a/core/modules/system/src/Tests/Image/ToolkitTestBase.php b/core/modules/system/src/Tests/Image/ToolkitTestBase.php
index 44b8437..72a3085 100644
--- a/core/modules/system/src/Tests/Image/ToolkitTestBase.php
+++ b/core/modules/system/src/Tests/Image/ToolkitTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Image;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 use Drupal\Component\Utility\String;
 
@@ -104,10 +105,10 @@ function assertToolkitOperationsCalled(array $expected) {
     // Determine if there were any expected that were not called.
     $uncalled = array_diff($expected, $actual);
     if (count($uncalled)) {
-      $this->assertTrue(FALSE, String::format('Expected operations %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
+      $this->assertTrue(FALSE, SafeMarkup::format('Expected operations %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
     }
     else {
-      $this->assertTrue(TRUE, String::format('All the expected operations were called: %expected', array('%expected' => implode(', ', $expected))));
+      $this->assertTrue(TRUE, SafeMarkup::format('All the expected operations were called: %expected', array('%expected' => implode(', ', $expected))));
     }
 
     // Determine if there were any unexpected calls.
@@ -115,7 +116,7 @@ function assertToolkitOperationsCalled(array $expected) {
     // count it as an error.
     $unexpected = array_diff($actual, $expected);
     if (count($unexpected) && (!in_array('apply', $expected) || count(array_intersect($unexpected, $operations)) !== count($unexpected))) {
-      $this->assertTrue(FALSE, String::format('Unexpected operations were called: %unexpected.', array('%unexpected' => implode(', ', $unexpected))));
+      $this->assertTrue(FALSE, SafeMarkup::format('Unexpected operations were called: %unexpected.', array('%unexpected' => implode(', ', $unexpected))));
     }
     else {
       $this->assertTrue(TRUE, 'No unexpected operations were called.');
diff --git a/core/modules/system/src/Tests/Installer/InstallerLanguageTest.php b/core/modules/system/src/Tests/Installer/InstallerLanguageTest.php
index a025b35..b989655 100644
--- a/core/modules/system/src/Tests/Installer/InstallerLanguageTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerLanguageTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Installer;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\KernelTestBase;
 use Drupal\Core\StringTranslation\Translator\FileTranslation;
 
@@ -33,9 +34,9 @@ function testInstallerTranslationFiles() {
     $file_translation = new FileTranslation(drupal_get_path('module', 'simpletest') . '/files/translations');
     foreach ($expected_translation_files as $langcode => $files_expected) {
       $files_found = $file_translation->findTranslationFiles($langcode);
-      $this->assertTrue(count($files_found) == count($files_expected), format_string('@count installer languages found.', array('@count' => count($files_expected))));
+      $this->assertTrue(count($files_found) == count($files_expected), SafeMarkup::format('@count installer languages found.', array('@count' => count($files_expected))));
       foreach ($files_found as $file) {
-        $this->assertTrue(in_array($file->filename, $files_expected), format_string('@file found.', array('@file' => $file->filename)));
+        $this->assertTrue(in_array($file->filename, $files_expected), SafeMarkup::format('@file found.', array('@file' => $file->filename)));
       }
     }
   }
diff --git a/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php b/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php
index a9d421a..55d67ab 100644
--- a/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php
+++ b/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php
@@ -89,7 +89,7 @@ protected function assertBreadcrumbParts($trail) {
     // No parts must be left, or an expected "Home" will always pass.
     $pass = ($pass && empty($parts));
 
-    $this->assertTrue($pass, format_string('Breadcrumb %parts found on @path.', array(
+    $this->assertTrue($pass, SafeMarkup::format('Breadcrumb %parts found on @path.', array(
       '%parts' => implode(' » ', $trail),
       '@path' => $this->getUrl(),
     )));
diff --git a/core/modules/system/src/Tests/Menu/AssertMenuActiveTrailTrait.php b/core/modules/system/src/Tests/Menu/AssertMenuActiveTrailTrait.php
index fba46d4..37ab35f 100644
--- a/core/modules/system/src/Tests/Menu/AssertMenuActiveTrailTrait.php
+++ b/core/modules/system/src/Tests/Menu/AssertMenuActiveTrailTrait.php
@@ -61,7 +61,7 @@ protected function assertMenuActiveTrail($tree, $last_active) {
       ':title' => $active_link_title,
     );
     $elements = $this->xpath($xpath, $args);
-    $this->assertTrue(!empty($elements), format_string('Active link %title was found in menu tree, including active trail links %tree.', array(
+    $this->assertTrue(!empty($elements), SafeMarkup::format('Active link %title was found in menu tree, including active trail links %tree.', array(
       '%title' => $active_link_title,
       '%tree' => implode(' » ', $tree),
     )));
diff --git a/core/modules/system/src/Tests/Menu/LocalTasksTest.php b/core/modules/system/src/Tests/Menu/LocalTasksTest.php
index 4edf30e..d88190c 100644
--- a/core/modules/system/src/Tests/Menu/LocalTasksTest.php
+++ b/core/modules/system/src/Tests/Menu/LocalTasksTest.php
@@ -38,7 +38,7 @@ protected function assertLocalTasks(array $routes, $level = 0) {
       list($route_name, $route_parameters) = $route_info;
       $expected = Url::fromRoute($route_name, $route_parameters)->toString();
       $method = ($elements[$index]['href'] == $expected ? 'pass' : 'fail');
-      $this->{$method}(format_string('Task @number href @value equals @expected.', array(
+      $this->{$method}(SafeMarkup::format('Task @number href @value equals @expected.', array(
         '@number' => $index + 1,
         '@value' => (string) $elements[$index]['href'],
         '@expected' => $expected,
diff --git a/core/modules/system/src/Tests/Module/InstallTest.php b/core/modules/system/src/Tests/Module/InstallTest.php
index 1068b60..233491e 100644
--- a/core/modules/system/src/Tests/Module/InstallTest.php
+++ b/core/modules/system/src/Tests/Module/InstallTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Module;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Extension\ExtensionNameLengthException;
 use Drupal\simpletest\WebTestBase;
 
@@ -60,7 +61,7 @@ public function testRequiredModuleSchemaVersions() {
    */
   public function testModuleNameLength() {
     $module_name = 'invalid_module_name_over_the_maximum_allowed_character_length';
-    $message = format_string('Exception thrown when enabling module %name with a name length over the allowed maximum', array('%name' => $module_name));
+    $message = SafeMarkup::format('Exception thrown when enabling module %name with a name length over the allowed maximum', array('%name' => $module_name));
     try {
       $this->container->get('module_installer')->install(array($module_name));
       $this->fail($message);
@@ -70,7 +71,7 @@ public function testModuleNameLength() {
     }
 
     // Since for the UI, the submit callback uses FALSE, test that too.
-    $message = format_string('Exception thrown when enabling as if via the UI the module %name with a name length over the allowed maximum', array('%name' => $module_name));
+    $message = SafeMarkup::format('Exception thrown when enabling as if via the UI the module %name with a name length over the allowed maximum', array('%name' => $module_name));
     try {
       $this->container->get('module_installer')->install(array($module_name), FALSE);
       $this->fail($message);
diff --git a/core/modules/system/src/Tests/Module/ModuleTestBase.php b/core/modules/system/src/Tests/Module/ModuleTestBase.php
index 4023b57..eb256f7 100644
--- a/core/modules/system/src/Tests/Module/ModuleTestBase.php
+++ b/core/modules/system/src/Tests/Module/ModuleTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Module;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Config\InstallStorage;
 use Drupal\Core\Database\Database;
 use Drupal\Core\Config\FileStorage;
@@ -47,9 +48,9 @@ function assertTableCount($base_table, $count = TRUE) {
     $tables = db_find_tables(Database::getConnection()->prefixTables('{' . $base_table . '}') . '%');
 
     if ($count) {
-      return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', array('@base_table' => $base_table)));
+      return $this->assertTrue($tables, SafeMarkup::format('Tables matching "@base_table" found.', array('@base_table' => $base_table)));
     }
-    return $this->assertFalse($tables, format_string('Tables matching "@base_table" not found.', array('@base_table' => $base_table)));
+    return $this->assertFalse($tables, SafeMarkup::format('Tables matching "@base_table" not found.', array('@base_table' => $base_table)));
   }
 
   /**
@@ -67,7 +68,7 @@ function assertModuleTablesExist($module) {
         $tables_exist = FALSE;
       }
     }
-    return $this->assertTrue($tables_exist, format_string('All database tables defined by the @module module exist.', array('@module' => $module)));
+    return $this->assertTrue($tables_exist, SafeMarkup::format('All database tables defined by the @module module exist.', array('@module' => $module)));
   }
 
   /**
@@ -84,7 +85,7 @@ function assertModuleTablesDoNotExist($module) {
         $tables_exist = TRUE;
       }
     }
-    return $this->assertFalse($tables_exist, format_string('None of the database tables defined by the @module module exist.', array('@module' => $module)));
+    return $this->assertFalse($tables_exist, SafeMarkup::format('None of the database tables defined by the @module module exist.', array('@module' => $module)));
   }
 
   /**
@@ -126,7 +127,7 @@ function assertModuleConfig($module) {
     }
     // Verify that all configuration has been installed (which means that $names
     // is empty).
-    return $this->assertFalse($names, format_string('All default configuration of @module module found.', array('@module' => $module)));
+    return $this->assertFalse($names, SafeMarkup::format('All default configuration of @module module found.', array('@module' => $module)));
   }
 
   /**
@@ -140,7 +141,7 @@ function assertModuleConfig($module) {
    */
   function assertNoModuleConfig($module) {
     $names = \Drupal::configFactory()->listAll($module . '.');
-    return $this->assertFalse($names, format_string('No configuration found for @module module.', array('@module' => $module)));
+    return $this->assertFalse($names, SafeMarkup::format('No configuration found for @module module.', array('@module' => $module)));
   }
 
   /**
@@ -160,7 +161,7 @@ function assertModules(array $modules, $enabled) {
       else {
         $message = 'Module "@module" is not enabled.';
       }
-      $this->assertEqual($this->container->get('module_handler')->moduleExists($module), $enabled, format_string($message, array('@module' => $module)));
+      $this->assertEqual($this->container->get('module_handler')->moduleExists($module), $enabled, SafeMarkup::format($message, array('@module' => $module)));
     }
   }
 
@@ -194,6 +195,6 @@ function assertLogMessage($type, $message, $variables = array(), $severity = Rfc
       ->countQuery()
       ->execute()
       ->fetchField();
-    $this->assertTrue($count > 0, format_string('watchdog table contains @count rows for @message', array('@count' => $count, '@message' => format_string($message, $variables))));
+    $this->assertTrue($count > 0, SafeMarkup::format('watchdog table contains @count rows for @message', array('@count' => $count, '@message' => SafeMarkup::format($message, $variables))));
   }
 }
diff --git a/core/modules/system/src/Tests/Module/RequiredTest.php b/core/modules/system/src/Tests/Module/RequiredTest.php
index c14d293..b614157 100644
--- a/core/modules/system/src/Tests/Module/RequiredTest.php
+++ b/core/modules/system/src/Tests/Module/RequiredTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\system\Tests\Module;
+use Drupal\Component\Utility\SafeMarkup;
 
 /**
  * Attempt disabling of required modules.
@@ -25,7 +26,7 @@ function testDisableRequired() {
       if (!empty($info['required'])) {
         $field_name = "modules[{$info['package']}][$module][enable]";
         if (empty($info['hidden'])) {
-          $this->assertFieldByXPath("//input[@name='$field_name' and @disabled='disabled' and @checked='checked']", '', format_string('Field @name was disabled and checked.', array('@name' => $field_name)));
+          $this->assertFieldByXPath("//input[@name='$field_name' and @disabled='disabled' and @checked='checked']", '', SafeMarkup::format('Field @name was disabled and checked.', array('@name' => $field_name)));
         }
         else {
           $this->assertNoFieldByName($field_name);
diff --git a/core/modules/system/src/Tests/Module/UninstallTest.php b/core/modules/system/src/Tests/Module/UninstallTest.php
index 4032a90..371e8f8 100644
--- a/core/modules/system/src/Tests/Module/UninstallTest.php
+++ b/core/modules/system/src/Tests/Module/UninstallTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Module;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Cache\Cache;
 use Drupal\Component\Utility\String;
 use Drupal\simpletest\WebTestBase;
@@ -66,7 +67,7 @@ function testUninstallPage() {
     $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
     $this->assertNoText(\Drupal::translation()->translate('Configuration deletions'), 'No configuration deletions listed on the module install confirmation page.');
     $this->assertText(\Drupal::translation()->translate('Configuration updates'), 'Configuration updates listed on the module install confirmation page.');
-    $this->assertText($node_type->label(), String::format('The entity label "!label" found.', array('!label' => $node_type->label())));
+    $this->assertText($node_type->label(), SafeMarkup::format('The entity label "!label" found.', array('!label' => $node_type->label())));
     $this->drupalPostForm(NULL, NULL, t('Uninstall'));
     $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
 
@@ -82,7 +83,7 @@ function testUninstallPage() {
     $entity_types = array();
     foreach ($node_dependencies as $entity) {
       $label = $entity->label() ?: $entity->id();
-      $this->assertText($label, String::format('The entity label "!label" found.', array('!label' => $label)));
+      $this->assertText($label, SafeMarkup::format('The entity label "!label" found.', array('!label' => $label)));
       $entity_types[] = $entity->getEntityTypeId();
     }
     $entity_types = array_unique($entity_types);
@@ -97,7 +98,7 @@ function testUninstallPage() {
     // cleared during the uninstall.
     \Drupal::cache()->set('uninstall_test', 'test_uninstall_page', Cache::PERMANENT);
     $cached = \Drupal::cache()->get('uninstall_test');
-    $this->assertEqual($cached->data, 'test_uninstall_page', String::format('Cache entry found: @bin', array('@bin' => $cached->data)));
+    $this->assertEqual($cached->data, 'test_uninstall_page', SafeMarkup::format('Cache entry found: @bin', array('@bin' => $cached->data)));
 
     $this->drupalPostForm(NULL, NULL, t('Uninstall'));
     $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
diff --git a/core/modules/system/src/Tests/Path/AliasTest.php b/core/modules/system/src/Tests/Path/AliasTest.php
index f1f6bf2..0fecb42 100644
--- a/core/modules/system/src/Tests/Path/AliasTest.php
+++ b/core/modules/system/src/Tests/Path/AliasTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Path;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Cache\MemoryCounterBackend;
 use Drupal\Core\Path\AliasStorage;
 use Drupal\Core\Database\Database;
@@ -37,7 +38,7 @@ function testCRUD() {
       $result = $connection->query('SELECT * FROM {url_alias} WHERE source = :source AND alias= :alias AND langcode = :langcode', array(':source' => $alias['source'], ':alias' => $alias['alias'], ':langcode' => $alias['langcode']));
       $rows = $result->fetchAll();
 
-      $this->assertEqual(count($rows), 1, format_string('Created an entry for %alias.', array('%alias' => $alias['alias'])));
+      $this->assertEqual(count($rows), 1, SafeMarkup::format('Created an entry for %alias.', array('%alias' => $alias['alias'])));
 
       //Cache the pid for further tests.
       $aliases[$idx]['pid'] = $rows[0]->pid;
@@ -47,12 +48,12 @@ function testCRUD() {
     foreach ($aliases as $alias) {
       $pid = $alias['pid'];
       $loadedAlias = $aliasStorage->load(array('pid' => $pid));
-      $this->assertEqual($loadedAlias, $alias, format_string('Loaded the expected path with pid %pid.', array('%pid' => $pid)));
+      $this->assertEqual($loadedAlias, $alias, SafeMarkup::format('Loaded the expected path with pid %pid.', array('%pid' => $pid)));
     }
 
     // Load alias by source path.
     $loadedAlias = $aliasStorage->load(array('source' => 'node/1'));
-    $this->assertEqual($loadedAlias['alias'], 'alias_for_node_1_und', format_string('The last created alias loaded by default.'));
+    $this->assertEqual($loadedAlias['alias'], 'alias_for_node_1_und', SafeMarkup::format('The last created alias loaded by default.'));
 
     //Update a few aliases
     foreach ($aliases as $alias) {
@@ -63,7 +64,7 @@ function testCRUD() {
       $result = $connection->query('SELECT pid FROM {url_alias} WHERE source = :source AND alias= :alias AND langcode = :langcode', array(':source' => $alias['source'], ':alias' => $alias['alias'] . '_updated', ':langcode' => $alias['langcode']));
       $pid = $result->fetchField();
 
-      $this->assertEqual($pid, $alias['pid'], format_string('Updated entry for pid %pid.', array('%pid' => $pid)));
+      $this->assertEqual($pid, $alias['pid'], SafeMarkup::format('Updated entry for pid %pid.', array('%pid' => $pid)));
     }
 
     //Delete a few aliases
@@ -74,7 +75,7 @@ function testCRUD() {
       $result = $connection->query('SELECT * FROM {url_alias} WHERE pid = :pid', array(':pid' => $pid));
       $rows = $result->fetchAll();
 
-      $this->assertEqual(count($rows), 0, format_string('Deleted entry with pid %pid.', array('%pid' => $pid)));
+      $this->assertEqual(count($rows), 0, SafeMarkup::format('Deleted entry with pid %pid.', array('%pid' => $pid)));
     }
   }
 
diff --git a/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php b/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php
index 1988708..03d0720 100644
--- a/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php
+++ b/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php
@@ -89,7 +89,7 @@ protected function assertUrlOutboundAlter($original, $final) {
     // Test outbound altering.
     $result = $this->container->get('url_generator')->generateFromPath($original);
     $final = Url::fromUri('internal:/' . $final)->toString();
-    $this->assertIdentical($result, $final, format_string('Altered outbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
+    $this->assertIdentical($result, $final, SafeMarkup::format('Altered outbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
   }
 
   /**
@@ -105,6 +105,6 @@ protected function assertUrlOutboundAlter($original, $final) {
   protected function assertUrlInboundAlter($original, $final) {
     // Test inbound altering.
     $result = $this->container->get('path.alias_manager')->getPathByAlias($original);
-    $this->assertIdentical($result, $final, format_string('Altered inbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
+    $this->assertIdentical($result, $final, SafeMarkup::format('Altered inbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
   }
 }
diff --git a/core/modules/system/src/Tests/Session/SessionTest.php b/core/modules/system/src/Tests/Session/SessionTest.php
index 0921f66..2256882 100644
--- a/core/modules/system/src/Tests/Session/SessionTest.php
+++ b/core/modules/system/src/Tests/Session/SessionTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Session;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -66,7 +67,7 @@ function testSessionSaveRegenerate() {
     );
     $this->drupalPostForm('user/login', $edit, t('Log in'));
     $this->drupalGet('user');
-    $pass = $this->assertText($user->getUsername(), format_string('Found name: %name', array('%name' => $user->getUsername())), 'User login');
+    $pass = $this->assertText($user->getUsername(), SafeMarkup::format('Found name: %name', array('%name' => $user->getUsername())), 'User login');
     $this->_logged_in = $pass;
 
     $this->drupalGet('session-test/id');
diff --git a/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php b/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php
index 2960064..2fa1f1d 100644
--- a/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php
+++ b/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\System;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\simpletest\WebTestBase;
 
@@ -29,7 +30,7 @@ protected function setUp() {
   public function testDefaultMetaTagsExist() {
     $this->drupalGet('');
     foreach ($this->default_metatags as $name => $metatag) {
-      $this->assertRaw($metatag, String::format('Default Mobile meta tag "@name" displayed properly.', array('@name' => $name)), 'System');
+      $this->assertRaw($metatag, SafeMarkup::format('Default Mobile meta tag "@name" displayed properly.', array('@name' => $name)), 'System');
     }
   }
 
@@ -40,7 +41,7 @@ public function testRemovingDefaultMetaTags() {
     \Drupal::service('module_installer')->install(array('system_module_test'));
     $this->drupalGet('');
     foreach ($this->default_metatags as $name => $metatag) {
-      $this->assertNoRaw($metatag, String::format('Default Mobile meta tag "@name" removed properly.', array('@name' => $name)), 'System');
+      $this->assertNoRaw($metatag, SafeMarkup::format('Default Mobile meta tag "@name" removed properly.', array('@name' => $name)), 'System');
     }
   }
 }
diff --git a/core/modules/system/src/Tests/System/ErrorHandlerTest.php b/core/modules/system/src/Tests/System/ErrorHandlerTest.php
index 9d1437f..5eda96e 100644
--- a/core/modules/system/src/Tests/System/ErrorHandlerTest.php
+++ b/core/modules/system/src/Tests/System/ErrorHandlerTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\System;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -144,10 +145,10 @@ function testExceptionHandler() {
     $this->assertTrue(strpos($this->drupalGetHeader(':status'), '500 Service unavailable (with message)'), 'Received expected HTTP status line.');
     // We cannot use assertErrorMessage() since the extact error reported
     // varies from database to database. Check that the SQL string is displayed.
-    $this->assertText($error_pdo_exception['%type'], format_string('Found %type in error page.', $error_pdo_exception));
-    $this->assertText($error_pdo_exception['!message'], format_string('Found !message in error page.', $error_pdo_exception));
-    $error_details = format_string('in %function (line ', $error_pdo_exception);
-    $this->assertRaw($error_details, format_string("Found '!message' in error page.", array('!message' => $error_details)));
+    $this->assertText($error_pdo_exception['%type'], SafeMarkup::format('Found %type in error page.', $error_pdo_exception));
+    $this->assertText($error_pdo_exception['!message'], SafeMarkup::format('Found !message in error page.', $error_pdo_exception));
+    $error_details = SafeMarkup::format('in %function (line ', $error_pdo_exception);
+    $this->assertRaw($error_details, SafeMarkup::format("Found '!message' in error page.", array('!message' => $error_details)));
 
     $this->drupalGet('error-test/trigger-renderer-exception');
     $this->assertTrue(strpos($this->drupalGetHeader(':status'), '500 Service unavailable (with message)'), 'Received expected HTTP status line.');
@@ -179,7 +180,7 @@ function testExceptionHandler() {
    */
   function assertErrorMessage(array $error) {
     $message = t('%type: !message in %function (line ', $error);
-    $this->assertRaw($message, format_string('Found error message: !message.', array('!message' => $message)));
+    $this->assertRaw($message, SafeMarkup::format('Found error message: !message.', array('!message' => $message)));
   }
 
   /**
@@ -187,6 +188,6 @@ function assertErrorMessage(array $error) {
    */
   function assertNoErrorMessage(array $error) {
     $message = t('%type: !message in %function (line ', $error);
-    $this->assertNoRaw($message, format_string('Did not find error message: !message.', array('!message' => $message)));
+    $this->assertNoRaw($message, SafeMarkup::format('Did not find error message: !message.', array('!message' => $message)));
   }
 }
diff --git a/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php b/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php
index 8aa38aa..b517333 100644
--- a/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php
+++ b/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\System;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Form\FormState;
 use Drupal\simpletest\WebTestBase;
 
@@ -62,7 +63,7 @@ public function testConfigForm() {
       '%values' => print_r($values, TRUE),
       '%errors' => $valid_form ? t('None') : implode(' ', $errors),
     );
-    $this->assertTrue($valid_form, format_string('Input values: %values<br/>Validation handler errors: %errors', $args));
+    $this->assertTrue($valid_form, SafeMarkup::format('Input values: %values<br/>Validation handler errors: %errors', $args));
 
     foreach ($this->values as $data) {
       $this->assertEqual($data['#value'], $this->config($data['#config_name'])->get($data['#config_key']));
diff --git a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php
index f489c75..ac845a6 100644
--- a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php
+++ b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php
@@ -41,7 +41,7 @@ public function testSystemTokenRecognition() {
       $input = $test['prefix'] . '[site:name]' . $test['suffix'];
       $expected = $test['prefix'] . 'Drupal' . $test['suffix'];
       $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()));
-      $this->assertTrue($output == $expected, format_string('Token recognized in string %string', array('%string' => $input)));
+      $this->assertTrue($output == $expected, SafeMarkup::format('Token recognized in string %string', array('%string' => $input)));
     }
 
     // Test token replacement when the string contains no tokens.
@@ -107,7 +107,7 @@ public function testSystemSiteTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()));
-      $this->assertEqual($output, $expected, format_string('Sanitized system site information token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Sanitized system site information token %token replaced.', array('%token' => $input)));
     }
 
     // Generate and test unsanitized tokens.
@@ -116,7 +116,7 @@ public function testSystemSiteTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId(), 'sanitize' => FALSE));
-      $this->assertEqual($output, $expected, format_string('Unsanitized system site information token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Unsanitized system site information token %token replaced.', array('%token' => $input)));
     }
 
     // Check that the results of Token::generate are sanitized properly. This
@@ -153,7 +153,7 @@ public function testSystemDateTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->interfaceLanguage->getId()));
-      $this->assertEqual($output, $expected, format_string('Date token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Date token %token replaced.', array('%token' => $input)));
     }
   }
 }
diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php
index a5766fa..8ae4466 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\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Session\UserSession;
 use Drupal\Core\Url;
@@ -197,7 +198,7 @@ function testLinks() {
         'title' => 'Plain "text"',
       ),
       'html text' => array(
-        'title' => String::format('<span class="unescaped">@text</span>', array('@text' => 'potentially unsafe text that <should> be escaped')),
+        'title' => SafeMarkup::format('<span class="unescaped">@text</span>', array('@text' => 'potentially unsafe text that <should> be escaped')),
       ),
       'front page' => array(
         'title' => 'Front page',
diff --git a/core/modules/system/src/Tests/Theme/ThemeTest.php b/core/modules/system/src/Tests/Theme/ThemeTest.php
index 0cd4e4e..2cee8af 100644
--- a/core/modules/system/src/Tests/Theme/ThemeTest.php
+++ b/core/modules/system/src/Tests/Theme/ThemeTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\system\Tests\Theme;
 
 use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 use Drupal\test_theme\ThemeClass;
 use Symfony\Cmf\Component\Routing\RouteObjectInterface;
@@ -64,7 +65,7 @@ function testThemeDataTypes() {
     $foos = array('null' => NULL, 'false' => FALSE, 'integer' => 1, 'string' => 'foo');
     foreach ($foos as $type => $example) {
       $output = \Drupal::theme()->render('theme_test_foo', array('foo' => $example));
-      $this->assertTrue(is_string($output), format_string('\Drupal::theme() returns a string for data type !type.', array('!type' => $type)));
+      $this->assertTrue(is_string($output), SafeMarkup::format('\Drupal::theme() returns a string for data type !type.', array('!type' => $type)));
     }
 
     // suggestionnotimplemented is not an implemented theme hook so \Drupal::theme() service
diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module
index 64418c7..ff52303 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.module
+++ b/core/modules/system/tests/modules/entity_test/entity_test.module
@@ -5,6 +5,7 @@
  * Test module for the entity API providing several entity types for testing.
  */
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Access\AccessResult;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\FieldableEntityInterface;
@@ -409,7 +410,7 @@ function entity_test_entity_operation_alter(array &$operations, EntityInterface
   if (in_array($entity->getEntityTypeId(), $valid_entity_type_ids)) {
     if (\Drupal::service('router.route_provider')->getRouteByName("entity.{$entity->getEntityTypeId()}.test_operation")) {
       $operations['test_operation'] = [
-        'title' => format_string('Test Operation: @label', ['@label' => $entity->label()]),
+        'title' => SafeMarkup::format('Test Operation: @label', ['@label' => $entity->label()]),
         'url' => Url::fromRoute("entity.{$entity->getEntityTypeId()}.test_operation", [$entity->getEntityTypeId() => $entity->id()]),
         'weight' => 50,
       ];
diff --git a/core/modules/system/tests/modules/menu_test/src/TestControllers.php b/core/modules/system/tests/modules/menu_test/src/TestControllers.php
index bbc4f1f..d7c7a2f 100644
--- a/core/modules/system/tests/modules/menu_test/src/TestControllers.php
+++ b/core/modules/system/tests/modules/menu_test/src/TestControllers.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\menu_test;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\EntityInterface;
 
@@ -54,10 +55,10 @@ public function testDerived() {
    */
   public function testDefaults($placeholder = NULL) {
     if ($placeholder) {
-      return ['#markup' => String::format("Sometimes there is a placeholder: '@placeholder'.", array('@placeholder' => $placeholder))];
+      return ['#markup' => SafeMarkup::format("Sometimes there is a placeholder: '@placeholder'.", array('@placeholder' => $placeholder))];
     }
     else {
-      return ['#markup' => String::format('Sometimes there is no placeholder.')];
+      return ['#markup' => SafeMarkup::format('Sometimes there is no placeholder.')];
     }
   }
 
diff --git a/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php b/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php
index f8d5614..0fcf61a 100644
--- a/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php
+++ b/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\session_test\Form;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
@@ -46,7 +47,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    * {@inheritdoc}
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
-    drupal_set_message(String::format('Ok: @input', array('@input' => $form_state->getValue('input'))));
+    drupal_set_message(SafeMarkup::format('Ok: @input', array('@input' => $form_state->getValue('input'))));
   }
 
 }
diff --git a/core/modules/taxonomy/src/Tests/EfqTest.php b/core/modules/taxonomy/src/Tests/EfqTest.php
index e8790cf..8ed7d71 100644
--- a/core/modules/taxonomy/src/Tests/EfqTest.php
+++ b/core/modules/taxonomy/src/Tests/EfqTest.php
@@ -62,7 +62,7 @@ function testTaxonomyEfq() {
       ->condition('vid', $vocabulary2->id())
       ->execute();
     sort($result);
-    $this->assertEqual(array_keys($terms2), $result, format_string('Taxonomy terms from the %name vocabulary were retrieved by entity query.', array('%name' => $vocabulary2->label())));
+    $this->assertEqual(array_keys($terms2), $result, SafeMarkup::format('Taxonomy terms from the %name vocabulary were retrieved by entity query.', array('%name' => $vocabulary2->label())));
     $tid = reset($result);
     $ids = (object) array(
       'entity_type' => 'taxonomy_term',
diff --git a/core/modules/taxonomy/src/Tests/LoadMultipleTest.php b/core/modules/taxonomy/src/Tests/LoadMultipleTest.php
index 4a2c1ce..a271613 100644
--- a/core/modules/taxonomy/src/Tests/LoadMultipleTest.php
+++ b/core/modules/taxonomy/src/Tests/LoadMultipleTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\taxonomy\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\taxonomy\Entity\Term;
 
 /**
@@ -38,7 +39,7 @@ function testTaxonomyTermMultipleLoad() {
     // Load the terms from the vocabulary.
     $terms = entity_load_multiple_by_properties('taxonomy_term', array('vid' => $vocabulary->id()));
     $count = count($terms);
-    $this->assertEqual($count, 5, format_string('Correct number of terms were loaded. !count terms.', array('!count' => $count)));
+    $this->assertEqual($count, 5, SafeMarkup::format('Correct number of terms were loaded. !count terms.', array('!count' => $count)));
 
     // Load the same terms again by tid.
     $terms2 = Term::loadMultiple(array_keys($terms));
diff --git a/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php
index 083e28b..8839296 100644
--- a/core/modules/taxonomy/src/Tests/TermTest.php
+++ b/core/modules/taxonomy/src/Tests/TermTest.php
@@ -287,28 +287,28 @@ function testNodeTermCreationAndDeletion() {
     $this->drupalGet('node/' . $node->id());
 
     foreach ($term_names as $term_name) {
-      $this->assertText($term_name, format_string('The term %name appears on the node page after two terms, %deleted1 and %deleted2, were deleted.', array('%name' => $term_name, '%deleted1' => $term_objects['term1']->getName(), '%deleted2' => $term_objects['term2']->getName())));
+      $this->assertText($term_name, SafeMarkup::format('The term %name appears on the node page after two terms, %deleted1 and %deleted2, were deleted.', array('%name' => $term_name, '%deleted1' => $term_objects['term1']->getName(), '%deleted2' => $term_objects['term2']->getName())));
     }
-    $this->assertNoText($term_objects['term1']->getName(), format_string('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term1']->getName())));
-    $this->assertNoText($term_objects['term2']->getName(), format_string('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term2']->getName())));
+    $this->assertNoText($term_objects['term1']->getName(), SafeMarkup::format('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term1']->getName())));
+    $this->assertNoText($term_objects['term2']->getName(), SafeMarkup::format('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term2']->getName())));
 
     // Test autocomplete on term 3, which contains a comma.
     // The term will be quoted, and the " will be encoded in unicode (\u0022).
     $input = substr($term_objects['term3']->getName(), 0, 3);
     $json = $this->drupalGet('taxonomy/autocomplete/node/taxonomy_' . $this->vocabulary->id(), array('query' => array('q' => $input)));
-    $this->assertEqual($json, '[{"value":"\u0022' . $term_objects['term3']->getName() . '\u0022","label":"' . $term_objects['term3']->getName() . '"}]', format_string('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term3']->getName())));
+    $this->assertEqual($json, '[{"value":"\u0022' . $term_objects['term3']->getName() . '\u0022","label":"' . $term_objects['term3']->getName() . '"}]', SafeMarkup::format('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term3']->getName())));
 
     // Test autocomplete on term 4 - it is alphanumeric only, so no extra
     // quoting.
     $input = substr($term_objects['term4']->getName(), 0, 3);
     $this->drupalGet('taxonomy/autocomplete/node/taxonomy_' . $this->vocabulary->id(), array('query' => array('q' => $input)));
-    $this->assertRaw('[{"value":"' . $term_objects['term4']->getName() . '","label":"' . $term_objects['term4']->getName() . '"}', format_string('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term4']->getName())));
+    $this->assertRaw('[{"value":"' . $term_objects['term4']->getName() . '","label":"' . $term_objects['term4']->getName() . '"}', SafeMarkup::format('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term4']->getName())));
 
     // Test taxonomy autocomplete with a nonexistent field.
     $field_name = $this->randomMachineName();
     $tag = $this->randomMachineName();
     $message = t("Taxonomy field @field_name not found.", array('@field_name' => $field_name));
-    $this->assertFalse(FieldStorageConfig::loadByName('node', $field_name), format_string('Field %field_name does not exist.', array('%field_name' => $field_name)));
+    $this->assertFalse(FieldStorageConfig::loadByName('node', $field_name), SafeMarkup::format('Field %field_name does not exist.', array('%field_name' => $field_name)));
     $this->drupalGet('taxonomy/autocomplete/node/' . $field_name, array('query' => array('q' => $tag)));
     $this->assertRaw($message, 'Autocomplete returns correct error message when the taxonomy field does not exist.');
   }
diff --git a/core/modules/taxonomy/src/Tests/TermValidationTest.php b/core/modules/taxonomy/src/Tests/TermValidationTest.php
index b369737..2d4bffb 100644
--- a/core/modules/taxonomy/src/Tests/TermValidationTest.php
+++ b/core/modules/taxonomy/src/Tests/TermValidationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\taxonomy\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\system\Tests\Entity\EntityUnitTestBase;
 
 /**
@@ -63,7 +64,7 @@ public function testValidation() {
     $term->set('parent', 9999);
     $violations = $term->validate();
     $this->assertEqual(count($violations), 1, 'Violation found when term parent is invalid.');
-    $this->assertEqual($violations[0]->getMessage(), format_string('The referenced entity (%type: %id) does not exist.', array('%type' => 'taxonomy_term', '%id' => 9999)));
+    $this->assertEqual($violations[0]->getMessage(), SafeMarkup::format('The referenced entity (%type: %id) does not exist.', array('%type' => 'taxonomy_term', '%id' => 9999)));
 
     $term->set('parent', 0);
     $violations = $term->validate();
diff --git a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php
index 242a23e..ce092e9 100644
--- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php
+++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php
@@ -105,7 +105,7 @@ function testTaxonomyTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->getId()));
-      $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
     }
 
     // Generate and test sanitized tokens for term2.
@@ -125,7 +125,7 @@ function testTaxonomyTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->getId()));
-      $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
     }
 
     // Generate and test unsanitized tokens.
@@ -136,7 +136,7 @@ function testTaxonomyTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE));
-      $this->assertEqual($output, $expected, format_string('Unsanitized taxonomy term token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Unsanitized taxonomy term token %token replaced.', array('%token' => $input)));
     }
 
     // Generate and test sanitized tokens.
@@ -152,7 +152,7 @@ function testTaxonomyTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->getId()));
-      $this->assertEqual($output, $expected, format_string('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input)));
     }
 
     // Generate and test unsanitized tokens.
@@ -161,7 +161,7 @@ function testTaxonomyTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE));
-      $this->assertEqual($output, $expected, format_string('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input)));
     }
   }
 }
diff --git a/core/modules/text/src/Tests/Formatter/TextFormatterTest.php b/core/modules/text/src/Tests/Formatter/TextFormatterTest.php
index cae892e..69dba19 100644
--- a/core/modules/text/src/Tests/Formatter/TextFormatterTest.php
+++ b/core/modules/text/src/Tests/Formatter/TextFormatterTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\text\Tests\Formatter;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\filter\Entity\FilterFormat;
 use Drupal\system\Tests\Entity\EntityUnitTestBase;
 
@@ -92,7 +93,7 @@ public function testFormatters() {
       $build = $entity->get('formatted_text')->view(array('type' => $formatter));
       drupal_render($build[0]);
       $this->assertEqual($build[0]['#markup'], "<p>Hello, world!</p>\n");
-      $this->assertEqual($build[0]['#cache']['tags'], FilterFormat::load('my_text_format')->getCacheTags(), format_string('The @formatter formatter has the expected cache tags when formatting a formatted text field.', array('@formatter' => $formatter)));
+      $this->assertEqual($build[0]['#cache']['tags'], FilterFormat::load('my_text_format')->getCacheTags(), SafeMarkup::format('The @formatter formatter has the expected cache tags when formatting a formatted text field.', array('@formatter' => $formatter)));
     }
   }
 
diff --git a/core/modules/text/src/Tests/TextFieldTest.php b/core/modules/text/src/Tests/TextFieldTest.php
index 494d338..afe3ebc 100644
--- a/core/modules/text/src/Tests/TextFieldTest.php
+++ b/core/modules/text/src/Tests/TextFieldTest.php
@@ -77,6 +77,59 @@ function testTextfieldWidgets() {
   }
 
   /**
+   * Helper function for testTextfieldWidgets().
+   */
+  function _testTextfieldWidgets($field_type, $widget_type) {
+    // Create a field.
+    $field_name = Unicode::strtolower($this->randomMachineName());
+    $field_storage = entity_create('field_storage_config', array(
+      'field_name' => $field_name,
+      'entity_type' => 'entity_test',
+      'type' => $field_type
+    ));
+    $field_storage->save();
+    entity_create('field_config', array(
+      'field_storage' => $field_storage,
+      'bundle' => 'entity_test',
+      'label' => $this->randomMachineName() . '_label',
+    ))->save();
+    entity_get_form_display('entity_test', 'entity_test', 'default')
+      ->setComponent($field_name, array(
+        'type' => $widget_type,
+        'settings' => array(
+          'placeholder' => 'A placeholder on ' . $widget_type,
+        ),
+      ))
+      ->save();
+    entity_get_display('entity_test', 'entity_test', 'full')
+      ->setComponent($field_name)
+      ->save();
+
+    // Display creation form.
+    $this->drupalGet('entity_test/add');
+    $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
+    $this->assertNoFieldByName("{$field_name}[0][format]", '1', 'Format selector is not displayed');
+    $this->assertRaw(SafeMarkup::format('placeholder="A placeholder on !widget_type"', array('!widget_type' => $widget_type)));
+
+    // Submit with some value.
+    $value = $this->randomMachineName();
+    $edit = array(
+      "{$field_name}[0][value]" => $value,
+    );
+    $this->drupalPostForm(NULL, $edit, t('Save'));
+    preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
+    $id = $match[1];
+    $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
+
+    // Display the entity.
+    $entity = entity_load('entity_test', $id);
+    $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
+    $content = $display->build($entity);
+    $this->drupalSetContent(drupal_render($content));
+    $this->assertText($value, 'Filtered tags are not displayed');
+  }
+
+  /**
    * Test widgets + 'formatted_text' setting.
    */
   function testTextfieldWidgetsFormatted() {
diff --git a/core/modules/text/src/Tests/TextSummaryTest.php b/core/modules/text/src/Tests/TextSummaryTest.php
index 6936114..fd39b1c 100644
--- a/core/modules/text/src/Tests/TextSummaryTest.php
+++ b/core/modules/text/src/Tests/TextSummaryTest.php
@@ -212,7 +212,7 @@ function testLength() {
    */
   function assertTextSummary($text, $expected, $format = NULL, $size = NULL) {
     $summary = text_summary($text, $format, $size);
-    $this->assertIdentical($summary, $expected, format_string('<pre style="white-space: pre-wrap">@actual</pre> is identical to <pre style="white-space: pre-wrap">@expected</pre>', array(
+    $this->assertIdentical($summary, $expected, SafeMarkup::format('<pre style="white-space: pre-wrap">@actual</pre> is identical to <pre style="white-space: pre-wrap">@expected</pre>', array(
       '@actual' => $summary,
       '@expected' => $expected,
     )));
diff --git a/core/modules/tour/src/Tests/TourTestBase.php b/core/modules/tour/src/Tests/TourTestBase.php
index c6372cd..90d98b7 100644
--- a/core/modules/tour/src/Tests/TourTestBase.php
+++ b/core/modules/tour/src/Tests/TourTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\tour\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -56,11 +57,11 @@ public function assertTourTips($tips = array()) {
       foreach ($tips as $tip) {
         if (!empty($tip['data-id'])) {
           $elements = \PHPUnit_Util_XML::cssSelect('#' . $tip['data-id'], TRUE, $this->content, TRUE);
-          $this->assertTrue(!empty($elements) && count($elements) === 1, format_string('Found corresponding page element for tour tip with id #%data-id', array('%data-id' => $tip['data-id'])));
+          $this->assertTrue(!empty($elements) && count($elements) === 1, SafeMarkup::format('Found corresponding page element for tour tip with id #%data-id', array('%data-id' => $tip['data-id'])));
         }
         else if (!empty($tip['data-class'])) {
           $elements = \PHPUnit_Util_XML::cssSelect('.' . $tip['data-class'], TRUE, $this->content, TRUE);
-          $this->assertFalse(empty($elements), format_string('Found corresponding page element for tour tip with class .%data-class', array('%data-class' => $tip['data-class'])));
+          $this->assertFalse(empty($elements), SafeMarkup::format('Found corresponding page element for tour tip with class .%data-class', array('%data-class' => $tip['data-class'])));
         }
         else {
           // It's a modal.
@@ -68,7 +69,7 @@ public function assertTourTips($tips = array()) {
         }
         $total++;
       }
-      $this->pass(format_string('Total %total Tips tested of which %modals modal(s).', array('%total' => $total, '%modals' => $modals)));
+      $this->pass(SafeMarkup::format('Total %total Tips tested of which %modals modal(s).', array('%total' => $total, '%modals' => $modals)));
     }
   }
 
diff --git a/core/modules/tracker/src/Tests/TrackerTest.php b/core/modules/tracker/src/Tests/TrackerTest.php
index 3ca1dc4..e63d927 100644
--- a/core/modules/tracker/src/Tests/TrackerTest.php
+++ b/core/modules/tracker/src/Tests/TrackerTest.php
@@ -327,7 +327,7 @@ function testTrackerCronIndexing() {
 
     // Assert that all node titles are displayed.
     foreach ($nodes as $i => $node) {
-      $this->assertText($node->label(), format_string('Node @i is displayed on the tracker listing pages.', array('@i' => $i)));
+      $this->assertText($node->label(), SafeMarkup::format('Node @i is displayed on the tracker listing pages.', array('@i' => $i)));
     }
     $this->assertText('1 new', 'One new comment is counted on the tracker listing pages.');
     $this->assertText('updated', 'Node is listed as updated');
@@ -337,7 +337,7 @@ function testTrackerCronIndexing() {
 
     // Assert that all node titles are displayed.
     foreach ($nodes as $i => $node) {
-      $this->assertText($node->label(), format_string('Node @i is displayed on the tracker listing pages.', array('@i' => $i)));
+      $this->assertText($node->label(), SafeMarkup::format('Node @i is displayed on the tracker listing pages.', array('@i' => $i)));
     }
     $this->assertText('1 new', 'New comment is counted on the tracker listing pages.');
   }
diff --git a/core/modules/user/src/PrivateTempStore.php b/core/modules/user/src/PrivateTempStore.php
index e99d5fc..f3fe9cf 100644
--- a/core/modules/user/src/PrivateTempStore.php
+++ b/core/modules/user/src/PrivateTempStore.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\user;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
 use Drupal\Core\Lock\LockBackendInterface;
@@ -122,7 +123,7 @@ public function set($key, $value) {
     if (!$this->lockBackend->acquire($key)) {
       $this->lockBackend->wait($key);
       if (!$this->lockBackend->acquire($key)) {
-        throw new TempStoreException(String::format("Couldn't acquire lock to update item %key in %collection temporary storage.", array(
+        throw new TempStoreException(SafeMarkup::format("Couldn't acquire lock to update item %key in %collection temporary storage.", array(
           '%key' => $key,
           '%collection' => $this->storage->getCollectionName(),
         )));
@@ -180,7 +181,7 @@ public function delete($key) {
     if (!$this->lockBackend->acquire($key)) {
       $this->lockBackend->wait($key);
       if (!$this->lockBackend->acquire($key)) {
-        throw new TempStoreException(String::format("Couldn't acquire lock to delete item %key from %collection temporary storage.", array(
+        throw new TempStoreException(SafeMarkup::format("Couldn't acquire lock to delete item %key from %collection temporary storage.", array(
           '%key' => $key,
           '%collection' => $this->storage->getCollectionName(),
         )));
diff --git a/core/modules/user/src/SharedTempStore.php b/core/modules/user/src/SharedTempStore.php
index 0049d79..cd95b01 100644
--- a/core/modules/user/src/SharedTempStore.php
+++ b/core/modules/user/src/SharedTempStore.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\user;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
 use Drupal\Core\Lock\LockBackendInterface;
@@ -185,7 +186,7 @@ public function set($key, $value) {
     if (!$this->lockBackend->acquire($key)) {
       $this->lockBackend->wait($key);
       if (!$this->lockBackend->acquire($key)) {
-        throw new TempStoreException(String::format("Couldn't acquire lock to update item %key in %collection temporary storage.", array(
+        throw new TempStoreException(SafeMarkup::format("Couldn't acquire lock to update item %key in %collection temporary storage.", array(
           '%key' => $key,
           '%collection' => $this->storage->getCollectionName(),
         )));
@@ -231,7 +232,7 @@ public function delete($key) {
     if (!$this->lockBackend->acquire($key)) {
       $this->lockBackend->wait($key);
       if (!$this->lockBackend->acquire($key)) {
-        throw new TempStoreException(String::format("Couldn't acquire lock to delete item %key from %collection temporary storage.", array(
+        throw new TempStoreException(SafeMarkup::format("Couldn't acquire lock to delete item %key from %collection temporary storage.", array(
           '%key' => $key,
           '%collection' => $this->storage->getCollectionName(),
         )));
diff --git a/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php b/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php
index f5dd8f2..707c354 100644
--- a/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php
+++ b/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php
@@ -155,7 +155,7 @@ public function testConditions() {
     $condition->setConfig('roles', array($this->role->id() => $this->role->id()));
     $condition->setConfig('negate', FALSE);
     $this->assertTrue($condition->execute(), 'Authenticated user is a member of the custom role.');
-    $this->assertEqual($condition->summary(), String::format('The user is a member of @roles', array('@roles' => $this->role->label())));
+    $this->assertEqual($condition->summary(), SafeMarkup::format('The user is a member of @roles', array('@roles' => $this->role->label())));
   }
 
 }
diff --git a/core/modules/user/src/Tests/UserDeleteTest.php b/core/modules/user/src/Tests/UserDeleteTest.php
index bfa6016..f116866 100644
--- a/core/modules/user/src/Tests/UserDeleteTest.php
+++ b/core/modules/user/src/Tests/UserDeleteTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\user\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -51,8 +52,8 @@ function testUserDeleteMultiple() {
       ->fetchField();
     $this->assertTrue($roles_after_deletion == 0, 'Role assigments deleted along with users');
     // Test if the users are deleted, user_load() will return FALSE.
-    $this->assertFalse(user_load($user_a->id()), format_string('User with id @uid deleted.', array('@uid' => $user_a->id())));
-    $this->assertFalse(user_load($user_b->id()), format_string('User with id @uid deleted.', array('@uid' => $user_b->id())));
-    $this->assertFalse(user_load($user_c->id()), format_string('User with id @uid deleted.', array('@uid' => $user_c->id())));
+    $this->assertFalse(user_load($user_a->id()), SafeMarkup::format('User with id @uid deleted.', array('@uid' => $user_a->id())));
+    $this->assertFalse(user_load($user_b->id()), SafeMarkup::format('User with id @uid deleted.', array('@uid' => $user_b->id())));
+    $this->assertFalse(user_load($user_c->id()), SafeMarkup::format('User with id @uid deleted.', array('@uid' => $user_c->id())));
   }
 }
diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php
index 447a7cb..03b7c23 100644
--- a/core/modules/user/src/Tests/UserRegistrationTest.php
+++ b/core/modules/user/src/Tests/UserRegistrationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\user\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\simpletest\WebTestBase;
 
@@ -278,9 +279,9 @@ function testRegistrationWithUserFields() {
       // Check user fields.
       $accounts = entity_load_multiple_by_properties('user', array('name' => $name, 'mail' => $mail));
       $new_user = reset($accounts);
-      $this->assertEqual($new_user->test_user_field[0]->value, $value, format_string('@js : The field value was correclty saved.', array('@js' => $js)));
-      $this->assertEqual($new_user->test_user_field[1]->value, $value + 1, format_string('@js : The field value was correclty saved.', array('@js' => $js)));
-      $this->assertEqual($new_user->test_user_field[2]->value, $value + 2, format_string('@js : The field value was correclty saved.', array('@js' => $js)));
+      $this->assertEqual($new_user->test_user_field[0]->value, $value, SafeMarkup::format('@js : The field value was correclty saved.', array('@js' => $js)));
+      $this->assertEqual($new_user->test_user_field[1]->value, $value + 1, SafeMarkup::format('@js : The field value was correclty saved.', array('@js' => $js)));
+      $this->assertEqual($new_user->test_user_field[2]->value, $value + 2, SafeMarkup::format('@js : The field value was correclty saved.', array('@js' => $js)));
     }
   }
 
diff --git a/core/modules/user/src/Tests/UserTokenReplaceTest.php b/core/modules/user/src/Tests/UserTokenReplaceTest.php
index 897e2aa..4437a59 100644
--- a/core/modules/user/src/Tests/UserTokenReplaceTest.php
+++ b/core/modules/user/src/Tests/UserTokenReplaceTest.php
@@ -70,7 +70,7 @@ function testUserTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->getId()));
-      $this->assertEqual($output, $expected, format_string('Sanitized user token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Sanitized user token %token replaced.', array('%token' => $input)));
     }
 
     // Generate and test unsanitized tokens.
@@ -80,7 +80,7 @@ function testUserTokenReplacement() {
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE));
-      $this->assertEqual($output, $expected, format_string('Unsanitized user token %token replaced.', array('%token' => $input)));
+      $this->assertEqual($output, $expected, SafeMarkup::format('Unsanitized user token %token replaced.', array('%token' => $input)));
     }
 
     // Generate login and cancel link.
diff --git a/core/modules/user/src/Tests/Views/BulkFormAccessTest.php b/core/modules/user/src/Tests/Views/BulkFormAccessTest.php
index 8f9b613..17ee4fc 100644
--- a/core/modules/user/src/Tests/Views/BulkFormAccessTest.php
+++ b/core/modules/user/src/Tests/Views/BulkFormAccessTest.php
@@ -58,7 +58,7 @@ public function testUserEditAccess() {
     $this->drupalPostForm('test-user-bulk-form', $edit, t('Apply'));
     $this->assertResponse(200);
 
-    $this->assertRaw(String::format('No access to execute %action on the @entity_type_label %entity_label.', [
+    $this->assertRaw(SafeMarkup::format('No access to execute %action on the @entity_type_label %entity_label.', [
       '%action' => 'Block the selected user(s)',
       '@entity_type_label' => 'User',
       '%entity_label' => $no_edit_user->label(),
diff --git a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
index 04cdef9..a0a9083 100644
--- a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
+++ b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\Tests\user\Unit;
 
-use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Access\AccessResult;
 use Drupal\Tests\UnitTestCase;
 use Drupal\user\UserAccessControlHandler;
@@ -125,7 +125,7 @@ public function assertFieldAccess($field, $viewer, $target, $view, $edit) {
       ->will($this->returnValue($this->{$target}));
 
     foreach (array('view' => $view, 'edit' => $edit) as $operation => $result) {
-      $message = String::format("User @field field access returns @result with operation '@op' for @account accessing @target", array(
+      $message = SafeMarkup::format("User @field field access returns @result with operation '@op' for @account accessing @target", array(
         '@field' => $field,
         '@result' => !isset($result) ? 'null' : ($result ? 'true' : 'false'),
         '@op' => $operation,
diff --git a/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php b/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php
index c579c2b..cad8507 100644
--- a/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php
+++ b/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Plugin\views;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Form\FormStateInterface;
 
@@ -60,7 +61,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
 
     foreach ($this->definition['original_configuration'] as $key => $value) {
       if (is_scalar($value)) {
-        $items[] = String::format('@key: @value', array('@key' => $key, '@value' => $value));
+        $items[] = SafeMarkup::format('@key: @value', array('@key' => $key, '@value' => $value));
       }
     }
 
diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php
index e277ac2..c806e47 100644
--- a/core/modules/views/src/Plugin/views/HandlerBase.php
+++ b/core/modules/views/src/Plugin/views/HandlerBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Plugin\views;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Component\Utility\UrlHelper;
@@ -721,7 +722,7 @@ public function getEntityType() {
       return $views_data['table']['entity type'];
     }
     else {
-      throw new \Exception(String::format('No entity type for field @field on view @view', array('@field' => $this->options['id'], '@view' => $this->view->storage->id())));
+      throw new \Exception(SafeMarkup::format('No entity type for field @field on view @view', array('@field' => $this->options['id'], '@view' => $this->view->storage->id())));
     }
   }
 
diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
index 5a4bda2..46168e9 100644
--- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
@@ -9,6 +9,7 @@
 
 use Drupal\Component\Plugin\DependentPluginInterface;
 use Drupal\Component\Utility\Html;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Cache\Cache;
@@ -1023,7 +1024,7 @@ public function optionLink($text, $section, $class = '', $title = '') {
     }
 
     if (!empty($class)) {
-      $text = String::format('<span>@text</span>', array('@text' => $text));
+      $text = SafeMarkup::format('<span>@text</span>', array('@text' => $text));
     }
 
     if (empty($title)) {
diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php
index d39ad46..278026f 100644
--- a/core/modules/views/src/Plugin/views/query/Sql.php
+++ b/core/modules/views/src/Plugin/views/query/Sql.php
@@ -1449,7 +1449,7 @@ function execute(ViewExecutable $view) {
           drupal_set_message($e->getMessage(), 'error');
         }
         else {
-          throw new DatabaseExceptionWrapper(format_string('Exception in @label[@view_name]: @message', array('@label' => $view->storage->label(), '@view_name' => $view->storage->id(), '@message' => $e->getMessage())));
+          throw new DatabaseExceptionWrapper(SafeMarkup::format('Exception in @label[@view_name]: @message', array('@label' => $view->storage->label(), '@view_name' => $view->storage->id(), '@message' => $e->getMessage())));
         }
       }
 
diff --git a/core/modules/views/src/Routing/ViewPageController.php b/core/modules/views/src/Routing/ViewPageController.php
index fd3ac25..3878e44 100644
--- a/core/modules/views/src/Routing/ViewPageController.php
+++ b/core/modules/views/src/Routing/ViewPageController.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Routing;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
 use Drupal\Core\Entity\EntityStorageInterface;
@@ -74,7 +75,7 @@ public static function create(ContainerInterface $container) {
   public function handle($view_id, $display_id, Request $request, RouteMatchInterface $route_match) {
     $entity = $this->storage->load($view_id);
     if (empty($entity)) {
-      throw new NotFoundHttpException(String::format('Page controller for view %id requested, but view was not found.', array('%id' => $view_id)));
+      throw new NotFoundHttpException(SafeMarkup::format('Page controller for view %id requested, but view was not found.', array('%id' => $view_id)));
     }
     $view = $this->executableFactory->get($entity);
     $view->setRequest($request);
diff --git a/core/modules/views/src/Tests/DefaultViewsTest.php b/core/modules/views/src/Tests/DefaultViewsTest.php
index 1d11868..b70d8fb 100644
--- a/core/modules/views/src/Tests/DefaultViewsTest.php
+++ b/core/modules/views/src/Tests/DefaultViewsTest.php
@@ -136,14 +136,14 @@ public function testDefaultViews() {
           $view->preExecute($this->viewArgMap[$name]);
         }
 
-        $this->assert(TRUE, format_string('View @view will be executed.', array('@view' => $view->storage->id())));
+        $this->assert(TRUE, SafeMarkup::format('View @view will be executed.', array('@view' => $view->storage->id())));
         $view->execute();
 
         $tokens = array('@name' => $name, '@display_id' => $display_id);
-        $this->assertTrue($view->executed, format_string('@name:@display_id has been executed.', $tokens));
+        $this->assertTrue($view->executed, SafeMarkup::format('@name:@display_id has been executed.', $tokens));
 
         $count = count($view->result);
-        $this->assertTrue($count > 0, format_string('@count results returned', array('@count' => $count)));
+        $this->assertTrue($count > 0, SafeMarkup::format('@count results returned', array('@count' => $count)));
         $view->destroy();
       }
     }
diff --git a/core/modules/views/src/Tests/Handler/AreaEntityTest.php b/core/modules/views/src/Tests/Handler/AreaEntityTest.php
index bc3fe6e..2ee9b67 100644
--- a/core/modules/views/src/Tests/Handler/AreaEntityTest.php
+++ b/core/modules/views/src/Tests/Handler/AreaEntityTest.php
@@ -72,9 +72,9 @@ public function testEntityAreaData() {
 
     // Test that all expected entity types have data.
     foreach (array_keys($expected_entities) as $entity) {
-      $this->assertTrue(!empty($data['entity_' . $entity]), format_string('Views entity area data found for @entity', array('@entity' => $entity)));
+      $this->assertTrue(!empty($data['entity_' . $entity]), SafeMarkup::format('Views entity area data found for @entity', array('@entity' => $entity)));
       // Test that entity_type is set correctly in the area data.
-      $this->assertEqual($entity, $data['entity_' . $entity]['area']['entity_type'], format_string('Correct entity_type set for @entity', array('@entity' => $entity)));
+      $this->assertEqual($entity, $data['entity_' . $entity]['area']['entity_type'], SafeMarkup::format('Correct entity_type set for @entity', array('@entity' => $entity)));
     }
 
     $expected_entities = array_filter($entity_types, function (EntityTypeInterface $type) {
@@ -83,7 +83,7 @@ public function testEntityAreaData() {
 
     // Test that no configuration entity types have data.
     foreach (array_keys($expected_entities) as $entity) {
-      $this->assertTrue(empty($data['entity_' . $entity]), format_string('Views config entity area data not found for @entity', array('@entity' => $entity)));
+      $this->assertTrue(empty($data['entity_' . $entity]), SafeMarkup::format('Views config entity area data not found for @entity', array('@entity' => $entity)));
     }
   }
 
diff --git a/core/modules/views/src/Tests/Handler/FieldCounterTest.php b/core/modules/views/src/Tests/Handler/FieldCounterTest.php
index 1290e67..ba13079 100644
--- a/core/modules/views/src/Tests/Handler/FieldCounterTest.php
+++ b/core/modules/views/src/Tests/Handler/FieldCounterTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Tests\Handler;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Tests\ViewUnitTestBase;
 use Drupal\views\Views;
 
@@ -51,11 +52,11 @@ function testSimple() {
     $view->preview();
 
     $counter = $view->style_plugin->getField(0, 'counter');
-    $this->assertEqual($counter, 1, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 1, '@counter' => $counter)));
+    $this->assertEqual($counter, 1, SafeMarkup::format('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 1, '@counter' => $counter)));
     $counter = $view->style_plugin->getField(1, 'counter');
-    $this->assertEqual($counter, 2, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 2, '@counter' => $counter)));
+    $this->assertEqual($counter, 2, SafeMarkup::format('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 2, '@counter' => $counter)));
     $counter = $view->style_plugin->getField(2, 'counter');
-    $this->assertEqual($counter, 3, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 3, '@counter' => $counter)));
+    $this->assertEqual($counter, 3, SafeMarkup::format('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 3, '@counter' => $counter)));
     $view->destroy();
 
     $view->setDisplay();
@@ -79,13 +80,13 @@ function testSimple() {
 
     $counter = $view->style_plugin->getField(0, 'counter');
     $expected_number = 0 + $rand_start;
-    $this->assertEqual($counter, $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
+    $this->assertEqual($counter, $expected_number, SafeMarkup::format('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
     $counter = $view->style_plugin->getField(1, 'counter');
     $expected_number = 1 + $rand_start;
-    $this->assertEqual($counter, $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
+    $this->assertEqual($counter, $expected_number, SafeMarkup::format('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
     $counter = $view->style_plugin->getField(2, 'counter');
     $expected_number = 2 + $rand_start;
-    $this->assertEqual($counter, $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
+    $this->assertEqual($counter, $expected_number, SafeMarkup::format('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
   }
 
   // @TODO: Write tests for pager.
diff --git a/core/modules/views/src/Tests/Handler/FieldUnitTest.php b/core/modules/views/src/Tests/Handler/FieldUnitTest.php
index 5ddd05e..60dfeed 100644
--- a/core/modules/views/src/Tests/Handler/FieldUnitTest.php
+++ b/core/modules/views/src/Tests/Handler/FieldUnitTest.php
@@ -98,7 +98,7 @@ public function testQuery() {
    *   The value to search for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
+   *   messages: use SafeMarkup::format() to embed variables in the message text, not
    *   t(). If left blank, a default message will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
@@ -122,7 +122,7 @@ protected function assertSubString($haystack, $needle, $message = '', $group = '
    *   The value to search for.
    * @param string $message
    *   (optional) A message to display with the assertion. Do not translate
-   *   messages: use format_string() to embed variables in the message text, not
+   *   messages: use SafeMarkup::format() to embed variables in the message text, not
    *   t(). If left blank, a default message will be displayed.
    * @param string $group
    *   (optional) The group this message is in, which is displayed in a column
@@ -183,19 +183,19 @@ public function testFieldTokens() {
       $expected_output_2 = "$row->views_test_data_name $row->views_test_data_name $row->views_test_data_name";
 
       $output = $name_field_0->advancedRender($row);
-      $this->assertEqual($output, $expected_output_0, format_string('Test token replacement: "!token" gave "!output"', [
+      $this->assertEqual($output, $expected_output_0, SafeMarkup::format('Test token replacement: "!token" gave "!output"', [
         '!token' => $name_field_0->options['alter']['text'],
         '!output' => $output,
       ]));
 
       $output = $name_field_1->advancedRender($row);
-      $this->assertEqual($output, $expected_output_1, format_string('Test token replacement: "!token" gave "!output"', [
+      $this->assertEqual($output, $expected_output_1, SafeMarkup::format('Test token replacement: "!token" gave "!output"', [
         '!token' => $name_field_1->options['alter']['text'],
         '!output' => $output,
       ]));
 
       $output = $name_field_2->advancedRender($row);
-      $this->assertEqual($output, $expected_output_2, format_string('Test token replacement: "!token" gave "!output"', [
+      $this->assertEqual($output, $expected_output_2, SafeMarkup::format('Test token replacement: "!token" gave "!output"', [
         '!token' => $name_field_2->options['alter']['text'],
         '!output' => $output,
       ]));
@@ -208,7 +208,7 @@ public function testFieldTokens() {
     $random_text = $this->randomMachineName();
     $job_field->setTestValue($random_text);
     $output = $job_field->advancedRender($row);
-    $this->assertSubString($output, $random_text, format_string('Make sure the self token (!token => !value) appears in the output (!output)', [
+    $this->assertSubString($output, $random_text, SafeMarkup::format('Make sure the self token (!token => !value) appears in the output (!output)', [
       '!value' => $random_text,
       '!output' => $output,
       '!token' => $job_field->options['alter']['text'],
@@ -220,7 +220,7 @@ public function testFieldTokens() {
     $random_text = $this->randomMachineName();
     $job_field->setTestValue($random_text);
     $output = $job_field->advancedRender($row);
-    $this->assertSubString($output, $old_token, format_string('Make sure the old token style (!token => !value) is not changed in the output (!output)', [
+    $this->assertSubString($output, $old_token, SafeMarkup::format('Make sure the old token style (!token => !value) is not changed in the output (!output)', [
       '!value' => $random_text,
       '!output' => $output,
       '!token' => $job_field->options['alter']['text'],
diff --git a/core/modules/views/src/Tests/Handler/FieldWebTest.php b/core/modules/views/src/Tests/Handler/FieldWebTest.php
index ceb8881..681ba45 100644
--- a/core/modules/views/src/Tests/Handler/FieldWebTest.php
+++ b/core/modules/views/src/Tests/Handler/FieldWebTest.php
@@ -490,12 +490,12 @@ public function testTextRendering() {
     $trimmed_name = Unicode::substr($row->views_test_data_name, 0, 5);
 
     $output = $name_field->advancedRender($row);
-    $this->assertSubString($output, $trimmed_name, format_string('Make sure the trimmed output (!trimmed) appears in the rendered output (!output).', array('!trimmed' => $trimmed_name, '!output' => $output)));
-    $this->assertNotSubString($output, $row->views_test_data_name, format_string("Make sure the untrimmed value (!untrimmed) shouldn't appear in the rendered output (!output).", array('!untrimmed' => $row->views_test_data_name, '!output' => $output)));
+    $this->assertSubString($output, $trimmed_name, SafeMarkup::format('Make sure the trimmed output (!trimmed) appears in the rendered output (!output).', array('!trimmed' => $trimmed_name, '!output' => $output)));
+    $this->assertNotSubString($output, $row->views_test_data_name, SafeMarkup::format("Make sure the untrimmed value (!untrimmed) shouldn't appear in the rendered output (!output).", array('!untrimmed' => $row->views_test_data_name, '!output' => $output)));
 
     $name_field->options['alter']['max_length'] = 9;
     $output = $name_field->advancedRender($row);
-    $this->assertSubString($output, $trimmed_name, format_string('Make sure the untrimmed (!untrimmed) output appears in the rendered output  (!output).', array('!trimmed' => $trimmed_name, '!output' => $output)));
+    $this->assertSubString($output, $trimmed_name, SafeMarkup::format('Make sure the untrimmed (!untrimmed) output appears in the rendered output  (!output).', array('!trimmed' => $trimmed_name, '!output' => $output)));
 
     // Take word_boundary into account for the tests.
     $name_field->options['alter']['max_length'] = 5;
@@ -537,10 +537,10 @@ public function testTextRendering() {
       $output = $name_field->advancedRender($row);
 
       if ($touple['trimmed']) {
-        $this->assertNotSubString($output, $touple['value'], format_string('The untrimmed value (!untrimmed) should not appear in the trimmed output (!output).', array('!untrimmed' => $touple['value'], '!output' => $output)));
+        $this->assertNotSubString($output, $touple['value'], SafeMarkup::format('The untrimmed value (!untrimmed) should not appear in the trimmed output (!output).', array('!untrimmed' => $touple['value'], '!output' => $output)));
       }
       if (!empty($touble['trimmed_value'])) {
-        $this->assertSubString($output, $touple['trimmed_value'], format_string('The trimmed value (!trimmed) should appear in the trimmed output (!output).', array('!trimmed' => $touple['trimmed_value'], '!output' => $output)));
+        $this->assertSubString($output, $touple['trimmed_value'], SafeMarkup::format('The trimmed value (!trimmed) should appear in the trimmed output (!output).', array('!trimmed' => $touple['trimmed_value'], '!output' => $output)));
       }
     }
 
diff --git a/core/modules/views/src/Tests/Handler/HandlerAllTest.php b/core/modules/views/src/Tests/Handler/HandlerAllTest.php
index 018ec2b..be70021 100644
--- a/core/modules/views/src/Tests/Handler/HandlerAllTest.php
+++ b/core/modules/views/src/Tests/Handler/HandlerAllTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\views\Tests\Handler;
 
 use Drupal\comment\Tests\CommentTestTrait;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\ViewExecutable;
 use Drupal\views\Plugin\views\HandlerBase;
 use Drupal\views\Plugin\views\filter\InOperator;
@@ -103,7 +104,7 @@ public function testHandlers() {
       foreach ($object_types as $type) {
         if (isset($view->{$type})) {
           foreach ($view->{$type} as $handler) {
-            $this->assertTrue($handler instanceof HandlerBase, format_string(
+            $this->assertTrue($handler instanceof HandlerBase, SafeMarkup::format(
               '@type handler of class %class is an instance of HandlerBase',
               array(
                 '@type' => $type,
diff --git a/core/modules/views/src/Tests/Handler/SortDateTest.php b/core/modules/views/src/Tests/Handler/SortDateTest.php
index 02d8807..0dcb892 100644
--- a/core/modules/views/src/Tests/Handler/SortDateTest.php
+++ b/core/modules/views/src/Tests/Handler/SortDateTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Tests\Handler;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\views\Tests\ViewUnitTestBase;
 use Drupal\views\Views;
@@ -198,7 +199,7 @@ public function testDateOrdering() {
         $this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
         $this->assertIdenticalResultset($view, $this->expectedResultSet($granularity, $reverse), array(
           'views_test_data_name' => 'name',
-        ), String::format('Result is returned correctly when ordering by granularity @granularity, @reverse.', array('@granularity' => $granularity, '@reverse' => $reverse ? 'reverse' : 'forward')));
+        ), SafeMarkup::format('Result is returned correctly when ordering by granularity @granularity, @reverse.', array('@granularity' => $granularity, '@reverse' => $reverse ? 'reverse' : 'forward')));
         $view->destroy();
         unset($view);
       }
diff --git a/core/modules/views/src/Tests/ModuleTest.php b/core/modules/views/src/Tests/ModuleTest.php
index cbb067e..366cc69 100644
--- a/core/modules/views/src/Tests/ModuleTest.php
+++ b/core/modules/views/src/Tests/ModuleTest.php
@@ -12,6 +12,7 @@
  *
  * @group views
  */
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Plugin\views\filter\Standard;
 use Drupal\views\Views;
 use Drupal\Component\Utility\String;
@@ -94,7 +95,7 @@ public function testViewsGetHandler() {
       'field' => 'field_invalid',
     );
     $this->container->get('plugin.manager.views.field')->getHandler($item);
-    $this->assertTrue(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'views_test_data', '@field' => 'field_invalid', '@type' => 'field'))) !== FALSE, 'An invalid field name throws a debug message.');
+    $this->assertTrue(strpos($this->lastErrorMessage, SafeMarkup::format("Missing handler: @table @field @type", array('@table' => 'views_test_data', '@field' => 'field_invalid', '@type' => 'field'))) !== FALSE, 'An invalid field name throws a debug message.');
     unset($this->lastErrorMessage);
 
     $item = array(
@@ -102,7 +103,7 @@ public function testViewsGetHandler() {
       'field' => 'id',
     );
     $this->container->get('plugin.manager.views.filter')->getHandler($item);
-    $this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.');
+    $this->assertEqual(strpos($this->lastErrorMessage, SafeMarkup::format("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.');
     unset($this->lastErrorMessage);
 
     $item = array(
@@ -110,7 +111,7 @@ public function testViewsGetHandler() {
       'field' => 'id',
     );
     $this->container->get('plugin.manager.views.filter')->getHandler($item);
-    $this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.');
+    $this->assertEqual(strpos($this->lastErrorMessage, SafeMarkup::format("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.');
     unset($this->lastErrorMessage);
 
     restore_error_handler();
@@ -258,7 +259,7 @@ public function testViewsPluginList() {
       list($plugin_type, $plugin_id) = explode(':', $key);
       $plugin_def = $this->container->get("plugin.manager.views.$plugin_type")->getDefinition($plugin_id);
 
-      $this->assertTrue(isset($plugin_list[$key]), String::format('The expected @key plugin list key was found.', array('@key' => $key)));
+      $this->assertTrue(isset($plugin_list[$key]), SafeMarkup::format('The expected @key plugin list key was found.', array('@key' => $key)));
       $plugin_details = $plugin_list[$key];
 
       $this->assertEqual($plugin_details['type'], $plugin_type, 'The expected plugin type was found.');
diff --git a/core/modules/views/src/Tests/Plugin/FilterTest.php b/core/modules/views/src/Tests/Plugin/FilterTest.php
index 63d90ab..7bf1f6b 100644
--- a/core/modules/views/src/Tests/Plugin/FilterTest.php
+++ b/core/modules/views/src/Tests/Plugin/FilterTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Tests\Plugin;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Views;
 use Drupal\views_test_data\Plugin\views\filter\FilterTest as FilterPlugin;
 
@@ -89,7 +90,7 @@ public function testFilterQuery() {
     $this->assertIdentical($view->filter['test_filter']->value, 'John');
 
     // Check that we have some results.
-    $this->assertEqual(count($view->result), 1, format_string('Results were returned. @count results.', array('@count' => count($view->result))));
+    $this->assertEqual(count($view->result), 1, SafeMarkup::format('Results were returned. @count results.', array('@count' => count($view->result))));
 
     $view->destroy();
 
@@ -115,7 +116,7 @@ public function testFilterQuery() {
 
     // Test that no nodes have been returned (Only 'page' type nodes should
     // exist).
-    $this->assertEqual(count($view->result), 4, format_string('No results were returned. @count results.', array('@count' => count($view->result))));
+    $this->assertEqual(count($view->result), 4, SafeMarkup::format('No results were returned. @count results.', array('@count' => count($view->result))));
 
     $view->destroy();
     $view->initDisplay();
@@ -139,7 +140,7 @@ public function testFilterQuery() {
     $this->executeView($view);
 
     // Check if we have all 5 results.
-    $this->assertEqual(count($view->result), 5, format_string('All @count results returned', array('@count' => count($view->displayHandlers))));
+    $this->assertEqual(count($view->result), 5, SafeMarkup::format('All @count results returned', array('@count' => count($view->displayHandlers))));
   }
 
 }
diff --git a/core/modules/views/src/Tests/Plugin/StyleMappingTest.php b/core/modules/views/src/Tests/Plugin/StyleMappingTest.php
index 24b06d2..8ebbf71 100644
--- a/core/modules/views/src/Tests/Plugin/StyleMappingTest.php
+++ b/core/modules/views/src/Tests/Plugin/StyleMappingTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Tests\Plugin;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Views;
 
 /**
@@ -73,7 +74,7 @@ protected function mappedOutputHelper($view) {
         // separated by ':'.
         $expected_result = $name . ':' . $data_set[$count][$field_id];
         $actual_result = (string) $field;
-        $this->assertIdentical($expected_result, $actual_result, format_string('The fields were mapped successfully: %name => %field_id', array('%name' => $name, '%field_id' => $field_id)));
+        $this->assertIdentical($expected_result, $actual_result, SafeMarkup::format('The fields were mapped successfully: %name => %field_id', array('%name' => $name, '%field_id' => $field_id)));
       }
 
       $count++;
diff --git a/core/modules/views/src/Tests/PluginInstanceTest.php b/core/modules/views/src/Tests/PluginInstanceTest.php
index 1893432..87a0f92 100644
--- a/core/modules/views/src/Tests/PluginInstanceTest.php
+++ b/core/modules/views/src/Tests/PluginInstanceTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Views;
 
 /**
@@ -65,8 +66,8 @@ public function testPluginData() {
 
     // Check all plugin types.
     foreach ($this->pluginTypes as $type) {
-      $this->assertTrue(array_key_exists($type, $this->definitions), format_string('Key for plugin type @type found.', array('@type' => $type)));
-      $this->assertTrue(is_array($this->definitions[$type]) && !empty($this->definitions[$type]), format_string('Plugin type @type has an array of plugins.', array('@type' => $type)));
+      $this->assertTrue(array_key_exists($type, $this->definitions), SafeMarkup::format('Key for plugin type @type found.', array('@type' => $type)));
+      $this->assertTrue(is_array($this->definitions[$type]) && !empty($this->definitions[$type]), SafeMarkup::format('Plugin type @type has an array of plugins.', array('@type' => $type)));
     }
 
     // Tests that the plugin list has not missed any types.
@@ -92,7 +93,7 @@ public function testPluginInstances() {
           // good to check they can be created but for throwing any notices for
           // method signatures etc... too.
           $instance = $manager->createInstance($id);
-          $this->assertTrue($instance instanceof $definition['class'], format_string('Instance of @type:@id created', array('@type' => $type, '@id' => $id)));
+          $this->assertTrue($instance instanceof $definition['class'], SafeMarkup::format('Instance of @type:@id created', array('@type' => $type, '@id' => $id)));
         }
       }
     }
diff --git a/core/modules/views/src/Tests/QueryGroupByTest.php b/core/modules/views/src/Tests/QueryGroupByTest.php
index b580e0a..4b23a54 100644
--- a/core/modules/views/src/Tests/QueryGroupByTest.php
+++ b/core/modules/views/src/Tests/QueryGroupByTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Views;
 
 /**
@@ -103,8 +104,8 @@ public function groupByTestHelper($aggregation_function, $values) {
     foreach ($view->result as $item) {
       $results[$item->entity_test_name] = $item->id;
     }
-    $this->assertEqual($results['name1'], $values[0], format_string('Aggregation with @aggregation_function and groupby name: name1 returned the expected amount of results', array('@aggregation_function' => $aggregation_function)));
-    $this->assertEqual($results['name2'], $values[1], format_string('Aggregation with @aggregation_function and groupby name: name2 returned the expected amount of results', array('@aggregation_function' => $aggregation_function)));
+    $this->assertEqual($results['name1'], $values[0], SafeMarkup::format('Aggregation with @aggregation_function and groupby name: name1 returned the expected amount of results', array('@aggregation_function' => $aggregation_function)));
+    $this->assertEqual($results['name2'], $values[1], SafeMarkup::format('Aggregation with @aggregation_function and groupby name: name2 returned the expected amount of results', array('@aggregation_function' => $aggregation_function)));
   }
 
   /**
diff --git a/core/modules/views/src/Tests/TokenReplaceTest.php b/core/modules/views/src/Tests/TokenReplaceTest.php
index d4bcc67..9806a76 100644
--- a/core/modules/views/src/Tests/TokenReplaceTest.php
+++ b/core/modules/views/src/Tests/TokenReplaceTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Views;
 
 /**
@@ -56,7 +57,7 @@ function testTokenReplacement() {
 
     foreach ($expected as $token => $expected_output) {
       $output = $token_handler->replace($token, array('view' => $view));
-      $this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', array('%token' => $token)));
+      $this->assertIdentical($output, $expected_output, SafeMarkup::format('Token %token replaced correctly.', array('%token' => $token)));
     }
   }
 
diff --git a/core/modules/views/src/Tests/ViewExecutableTest.php b/core/modules/views/src/Tests/ViewExecutableTest.php
index 6555c5b..b6de575 100644
--- a/core/modules/views/src/Tests/ViewExecutableTest.php
+++ b/core/modules/views/src/Tests/ViewExecutableTest.php
@@ -126,7 +126,7 @@ public function testInitMethods() {
       if ($type == 'relationship') {
         continue;
       }
-      $this->assertTrue(count($view->$type), format_string('Make sure a %type instance got instantiated.', array('%type' => $type)));
+      $this->assertTrue(count($view->$type), SafeMarkup::format('Make sure a %type instance got instantiated.', array('%type' => $type)));
     }
 
     // initHandlers() should create display handlers automatically as well.
@@ -423,7 +423,7 @@ public function testValidate() {
       $match = function($value) use ($display) {
         return strpos($value, $display->display['display_title']) !== false;
       };
-      $this->assertTrue(array_filter($validate[$id], $match), format_string('Error message found for @id display', array('@id' => $id)));
+      $this->assertTrue(array_filter($validate[$id], $match), SafeMarkup::format('Error message found for @id display', array('@id' => $id)));
       $count++;
     }
 
diff --git a/core/modules/views/src/Tests/ViewResultAssertionTrait.php b/core/modules/views/src/Tests/ViewResultAssertionTrait.php
index 222bf25..b38125b 100644
--- a/core/modules/views/src/Tests/ViewResultAssertionTrait.php
+++ b/core/modules/views/src/Tests/ViewResultAssertionTrait.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Plugin\views\field\Field;
 use Drupal\views\ViewExecutable;
 
@@ -127,7 +128,7 @@ protected function assertIdenticalResultsetHelper($view, $expected_result, $colu
     // Do the actual comparison.
     if (!isset($message)) {
       $not = (strpos($assert_method, 'Not') ? 'not' : '');
-      $message = format_string("Actual result <pre>\n@actual\n</pre> is $not identical to expected <pre>\n@expected\n</pre>", array(
+      $message = SafeMarkup::format("Actual result <pre>\n@actual\n</pre> is $not identical to expected <pre>\n@expected\n</pre>", array(
         '@actual' => var_export($result, TRUE),
         '@expected' => var_export($expected_result, TRUE),
       ));
diff --git a/core/modules/views/src/Tests/ViewStorageTest.php b/core/modules/views/src/Tests/ViewStorageTest.php
index 1a0f5ac..605cdb3 100644
--- a/core/modules/views/src/Tests/ViewStorageTest.php
+++ b/core/modules/views/src/Tests/ViewStorageTest.php
@@ -93,7 +93,7 @@ protected function loadTests() {
     // expected properties.
     $this->assertTrue($view instanceof View, 'Single View instance loaded.');
     foreach ($this->configProperties as $property) {
-      $this->assertTrue($view->get($property) !== NULL, format_string('Property: @property loaded onto View.', array('@property' => $property)));
+      $this->assertTrue($view->get($property) !== NULL, SafeMarkup::format('Property: @property loaded onto View.', array('@property' => $property)));
     }
 
     // Check the displays have been loaded correctly from config display data.
@@ -109,7 +109,7 @@ protected function loadTests() {
       // exists.
       $original_options = $data['display'][$key];
       foreach ($original_options as $orig_key => $value) {
-        $this->assertIdentical($display[$orig_key], $value, format_string('@key is identical to saved data', array('@key' => $key)));
+        $this->assertIdentical($display[$orig_key], $value, SafeMarkup::format('@key is identical to saved data', array('@key' => $key)));
       }
     }
 
@@ -128,7 +128,7 @@ protected function createTests() {
     $this->assertTrue($created instanceof View, 'Created object is a View.');
     // Check that the View contains all of the properties.
     foreach ($this->configProperties as $property) {
-      $this->assertTrue(property_exists($created, $property), format_string('Property: @property created on View.', array('@property' => $property)));
+      $this->assertTrue(property_exists($created, $property), SafeMarkup::format('Property: @property created on View.', array('@property' => $property)));
     }
 
     // Create a new View instance with config values.
@@ -145,8 +145,8 @@ protected function createTests() {
 
     // Test all properties except displays.
     foreach ($properties as $property) {
-      $this->assertTrue($created->get($property) !== NULL, format_string('Property: @property created on View.', array('@property' => $property)));
-      $this->assertIdentical($values[$property], $created->get($property), format_string('Property value: @property matches configuration value.', array('@property' => $property)));
+      $this->assertTrue($created->get($property) !== NULL, SafeMarkup::format('Property: @property created on View.', array('@property' => $property)));
+      $this->assertIdentical($values[$property], $created->get($property), SafeMarkup::format('Property value: @property matches configuration value.', array('@property' => $property)));
     }
 
     // Check the UUID of the loaded View.
@@ -218,14 +218,14 @@ protected function displayMethodTests() {
     $random_title = $this->randomMachineName();
 
     $id = $view->addDisplay('page', $random_title);
-    $this->assertEqual($id, 'page_1', format_string('Make sure the first display (%id_new) has the expected ID (%id)', array('%id_new' => $id, '%id' => 'page_1')));
+    $this->assertEqual($id, 'page_1', SafeMarkup::format('Make sure the first display (%id_new) has the expected ID (%id)', array('%id_new' => $id, '%id' => 'page_1')));
     $display = $view->get('display');
     $this->assertEqual($display[$id]['display_title'], $random_title);
 
     $random_title = $this->randomMachineName();
     $id = $view->addDisplay('page', $random_title);
     $display = $view->get('display');
-    $this->assertEqual($id, 'page_2', format_string('Make sure the second display (%id_new) has the expected ID (%id)', array('%id_new' => $id, '%id' => 'page_2')));
+    $this->assertEqual($id, 'page_2', SafeMarkup::format('Make sure the second display (%id_new) has the expected ID (%id)', array('%id_new' => $id, '%id' => 'page_2')));
     $this->assertEqual($display[$id]['display_title'], $random_title);
 
     $id = $view->addDisplay('page');
@@ -348,14 +348,14 @@ public function testCreateDuplicate() {
     );
 
     foreach ($config_properties as $property) {
-      $this->assertIdentical($view->storage->get($property), $copy->get($property), format_string('@property property is identical.', array('@property' => $property)));
+      $this->assertIdentical($view->storage->get($property), $copy->get($property), SafeMarkup::format('@property property is identical.', array('@property' => $property)));
     }
 
     // Check the displays are the same.
     $copy_display = $copy->get('display');
     foreach ($view->storage->get('display') as $id => $display) {
       // assertIdentical will not work here.
-      $this->assertEqual($display, $copy_display[$id], format_string('The @display display has been copied correctly.', array('@display' => $id)));
+      $this->assertEqual($display, $copy_display[$id], SafeMarkup::format('The @display display has been copied correctly.', array('@display' => $id)));
     }
   }
 
diff --git a/core/modules/views/src/Tests/ViewsHooksTest.php b/core/modules/views/src/Tests/ViewsHooksTest.php
index 534df07..4d8df00 100644
--- a/core/modules/views/src/Tests/ViewsHooksTest.php
+++ b/core/modules/views/src/Tests/ViewsHooksTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Views;
 
 /**
@@ -68,7 +69,7 @@ public function testHooks() {
 
     // Test each hook is found in the implementations array and is invoked.
     foreach (static::$hooks as $hook => $type) {
-      $this->assertTrue($this->moduleHandler->implementsHook('views_test_data', $hook), format_string('The hook @hook was registered.', array('@hook' => $hook)));
+      $this->assertTrue($this->moduleHandler->implementsHook('views_test_data', $hook), SafeMarkup::format('The hook @hook was registered.', array('@hook' => $hook)));
 
       switch ($type) {
         case 'view':
@@ -84,7 +85,7 @@ public function testHooks() {
           $this->moduleHandler->invoke('views_test_data', $hook);
       }
 
-      $this->assertTrue($this->container->get('state')->get('views_hook_test_' . $hook), format_string('The %hook hook was invoked.', array('%hook' => $hook)));
+      $this->assertTrue($this->container->get('state')->get('views_hook_test_' . $hook), SafeMarkup::format('The %hook hook was invoked.', array('%hook' => $hook)));
       // Reset the module implementations cache, so we ensure that the
       // .views.inc file is loaded actively.
       $this->moduleHandler->resetImplementations();
diff --git a/core/modules/views/src/Tests/Wizard/BasicTest.php b/core/modules/views/src/Tests/Wizard/BasicTest.php
index 5871afc..d8f0b1a 100644
--- a/core/modules/views/src/Tests/Wizard/BasicTest.php
+++ b/core/modules/views/src/Tests/Wizard/BasicTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\views\Tests\Wizard;
 
 use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Url;
 use Drupal\views\Views;
@@ -207,7 +208,7 @@ public function testWizardDefaultValues() {
 
     foreach ($displays as $display) {
       foreach (array('query', 'exposed_form', 'pager', 'style', 'row') as $type) {
-        $this->assertFalse(empty($display['display_options'][$type]['options']), String::format('Default options found for @plugin.', array('@plugin' => $type)));
+        $this->assertFalse(empty($display['display_options'][$type]['options']), SafeMarkup::format('Default options found for @plugin.', array('@plugin' => $type)));
       }
     }
   }
diff --git a/core/modules/views/src/Tests/Wizard/MenuTest.php b/core/modules/views/src/Tests/Wizard/MenuTest.php
index 6f29329..fbb14f9 100644
--- a/core/modules/views/src/Tests/Wizard/MenuTest.php
+++ b/core/modules/views/src/Tests/Wizard/MenuTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Tests\Wizard;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Url;
 
@@ -49,7 +50,7 @@ function testMenus() {
     /** @var \Drupal\Core\Menu\MenuLinkInterface $link */
     $link = $menu_link_manager->createInstance('views_view:views.' . $view['id'] . '.page_1');
     $url = $link->getUrlObject();
-    $this->assertEqual($url->getRouteName(), 'view.' . $view['id'] . '.page_1', String::format('Found a link to %path in the main menu', array('%path' => $view['page[path]'])));
+    $this->assertEqual($url->getRouteName(), 'view.' . $view['id'] . '.page_1', SafeMarkup::format('Found a link to %path in the main menu', array('%path' => $view['page[path]'])));
     $metadata = $link->getMetaData();
     $this->assertEqual(array('view_id' => $view['id'], 'display_id' => 'page_1'), $metadata);
   }
diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php
index 11dce89..4c5d1c8 100644
--- a/core/modules/views/src/ViewExecutable.php
+++ b/core/modules/views/src/ViewExecutable.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\DependencyInjection\DependencySerializationTrait;
@@ -720,7 +721,7 @@ public function setDisplay($display_id = NULL) {
 
     // Ensure the requested display exists.
     if (!$this->displayHandlers->has($display_id)) {
-      debug(format_string('setDisplay() called with invalid display ID "@display".', array('@display' => $display_id)));
+      debug(SafeMarkup::format('setDisplay() called with invalid display ID "@display".', array('@display' => $display_id)));
       return FALSE;
     }
 
@@ -1859,7 +1860,7 @@ public function getUrl($args = NULL, $display_id = NULL) {
   public function getUrlInfo($display_id = '') {
     $this->initDisplay();
     if (!$this->display_handler instanceof DisplayRouterInterface) {
-      throw new \InvalidArgumentException(String::format('You cannot generate a URL for the display @display_id', ['@display_id' => $display_id]));
+      throw new \InvalidArgumentException(SafeMarkup::format('You cannot generate a URL for the display @display_id', ['@display_id' => $display_id]));
     }
     return $this->display_handler->getUrlInfo();
   }
diff --git a/core/modules/views/src/ViewsDataHelper.php b/core/modules/views/src/ViewsDataHelper.php
index b986746..eed1dd1 100644
--- a/core/modules/views/src/ViewsDataHelper.php
+++ b/core/modules/views/src/ViewsDataHelper.php
@@ -7,8 +7,8 @@
 
 namespace Drupal\views;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
-use Drupal\Component\Utility\String;
 
 /**
  * Defines a helper class for stuff related to views data.
@@ -116,7 +116,7 @@ public function fetchFields($base, $type, $grouping = FALSE, $sub_type = NULL) {
                 }
                 else {
                   if ($string != 'base' && $string != 'base') {
-                    $strings[$field][$key][$string] = String::format("Error: missing @component", array('@component' => $string));
+                    $strings[$field][$key][$string] = SafeMarkup::format("Error: missing @component", array('@component' => $string));
                   }
                 }
               }
diff --git a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php
index ee3cb03..95fd6c7 100644
--- a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php
+++ b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php
@@ -868,11 +868,11 @@ public function setKey($key, $value) {
 
 
 namespace {
-  use Drupal\Component\Utility\String;
+  use Drupal\Component\Utility\SafeMarkup;
 
   if (!function_exists('t')) {
     function t($string, array $args = []) {
-      return String::format($string, $args);
+      return SafeMarkup::format($string, $args);
     }
   }
 }
diff --git a/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php b/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php
index 7b0c14d..2a968e3 100644
--- a/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Tests\views\Unit\Plugin\field;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Tests\UnitTestCase;
 use Drupal\views\Entity\View;
@@ -126,12 +127,12 @@ public function testSimpleCounter($i) {
     $expected = $i + 1;
 
     $counter = $counter_handler->getValue($this->testData[$i]);
-    $this->assertEquals($expected, $counter, String::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
+    $this->assertEquals($expected, $counter, SafeMarkup::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
       '@expected' => $expected,
       '@counter' => $counter
     )));
     $counter = $counter_handler->render($this->testData[$i]);
-    $this->assertEquals($expected, $counter_handler->render($this->testData[$i]), String::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
+    $this->assertEquals($expected, $counter_handler->render($this->testData[$i]), SafeMarkup::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
       '@expected' => $expected,
       '@counter' => $counter
     )));
@@ -158,12 +159,12 @@ public function testCounterRandomStart($i) {
     $expected = $rand_start + $i;
 
     $counter = $counter_handler->getValue($this->testData[$i]);
-    $this->assertEquals($expected, $counter, String::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
+    $this->assertEquals($expected, $counter, SafeMarkup::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
       '@expected' => $expected,
       '@counter' => $counter
     )));
     $counter = $counter_handler->render($this->testData[$i]);
-    $this->assertEquals($expected, $counter_handler->render($this->testData[$i]), String::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
+    $this->assertEquals($expected, $counter_handler->render($this->testData[$i]), SafeMarkup::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
       '@expected' => $expected,
       '@counter' => $counter
     )));
@@ -193,12 +194,12 @@ public function testCounterRandomPagerOffset($i) {
     $expected = $offset + $rand_start + $i;
 
     $counter = $counter_handler->getValue($this->testData[$i]);
-    $this->assertEquals($expected, $counter, String::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
+    $this->assertEquals($expected, $counter, SafeMarkup::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
       '@expected' => $expected,
       '@counter' => $counter
     )));
     $counter = $counter_handler->render($this->testData[$i]);
-    $this->assertEquals($expected, $counter_handler->render($this->testData[$i]), String::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
+    $this->assertEquals($expected, $counter_handler->render($this->testData[$i]), SafeMarkup::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
       '@expected' => $expected,
       '@counter' => $counter
     )));
@@ -232,12 +233,12 @@ public function testCounterSecondPage($i) {
     $expected = $items_per_page + $offset + $rand_start + $i;
 
     $counter = $counter_handler->getValue($this->testData[$i]);
-    $this->assertEquals($expected, $counter, String::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
+    $this->assertEquals($expected, $counter, SafeMarkup::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
       '@expected' => $expected,
       '@counter' => $counter
     )));
     $counter = $counter_handler->render($this->testData[$i]);
-    $this->assertEquals($expected, $counter_handler->render($this->testData[$i]), String::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
+    $this->assertEquals($expected, $counter_handler->render($this->testData[$i]), SafeMarkup::format('The expected number (@expected) patches with the rendered number (@counter) failed', array(
       '@expected' => $expected,
       '@counter' => $counter
     )));
diff --git a/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php b/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php
index 9016dbf..bb10483 100644
--- a/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php
+++ b/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Tests\views\Unit;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Tests\UnitTestCase;
 use Drupal\views\ViewsDataHelper;
@@ -106,7 +107,7 @@ public function testFetchFields() {
       array_walk($expected_keys, function(&$item) {
         $item = "views_test_data.$item";
       });
-      $this->assertEquals($expected_keys, array_keys($fields), String::format('Handlers of type @handler_type are not listed as expected.', array('@handler_type' => $handler_type)));
+      $this->assertEquals($expected_keys, array_keys($fields), SafeMarkup::format('Handlers of type @handler_type are not listed as expected.', array('@handler_type' => $handler_type)));
     }
 
     // Check for subtype filtering, so header and footer.
@@ -117,7 +118,7 @@ public function testFetchFields() {
       array_walk($expected_keys, function(&$item) {
         $item = "views_test_data.$item";
       });
-      $this->assertEquals($expected_keys, array_keys($fields), String::format('Sub_type @sub_type is not filtered as expected.', array('@sub_type' => $sub_type)));
+      $this->assertEquals($expected_keys, array_keys($fields), SafeMarkup::format('Sub_type @sub_type is not filtered as expected.', array('@sub_type' => $sub_type)));
     }
   }
 
diff --git a/core/modules/views_ui/src/Form/Ajax/Rearrange.php b/core/modules/views_ui/src/Form/Ajax/Rearrange.php
index 9e2259f..7c14944 100644
--- a/core/modules/views_ui/src/Form/Ajax/Rearrange.php
+++ b/core/modules/views_ui/src/Form/Ajax/Rearrange.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views_ui\Form\Ajax;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Url;
@@ -129,7 +130,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
         '#id' => 'views-removed-' . $id,
         '#attributes' => array('class' => array('views-remove-checkbox')),
         '#default_value' => 0,
-        '#suffix' => \Drupal::l(String::format('<span>@text</span>', array('@text' => $this->t('Remove'))),
+        '#suffix' => \Drupal::l(SafeMarkup::format('<span>@text</span>', array('@text' => $this->t('Remove'))),
           Url::fromRoute('<none>', array(), array('attributes' => array(
             'id' => 'views-remove-link-' . $id,
             'class' => array('views-hidden', 'views-button-remove', 'views-remove-link'),
diff --git a/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php b/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php
index c2415ff..72924d1 100644
--- a/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php
+++ b/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views_ui\Form\Ajax;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Url;
@@ -121,7 +122,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
         ),
         'link' => array(
           '#type' => 'link',
-          '#title' => String::format('<span>@text</span>', array('@text' => $this->t('Remove'))),
+          '#title' => SafeMarkup::format('<span>@text</span>', array('@text' => $this->t('Remove'))),
           '#url' => Url::fromRoute('<none>'),
           '#attributes' => array(
             'id' => 'display-remove-link-' . $id,
diff --git a/core/modules/views_ui/src/Tests/AnalyzeTest.php b/core/modules/views_ui/src/Tests/AnalyzeTest.php
index 0d82239..1469b02 100644
--- a/core/modules/views_ui/src/Tests/AnalyzeTest.php
+++ b/core/modules/views_ui/src/Tests/AnalyzeTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views_ui\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Tests\ViewTestBase;
 
 /**
@@ -54,7 +55,7 @@ function testAnalyzeBasic() {
 
     foreach (array('ok', 'warning', 'error') as $type) {
       $xpath = $this->xpath('//div[contains(@class, :class)]', array(':class' => $type));
-      $this->assertTrue(count($xpath), format_string('Analyse messages with @type found', array('@type' => $type)));
+      $this->assertTrue(count($xpath), SafeMarkup::format('Analyse messages with @type found', array('@type' => $type)));
     }
 
     // This redirects the user back to the main views edit page.
diff --git a/core/modules/views_ui/src/Tests/CustomBooleanTest.php b/core/modules/views_ui/src/Tests/CustomBooleanTest.php
index f9a990b..57f3e79 100644
--- a/core/modules/views_ui/src/Tests/CustomBooleanTest.php
+++ b/core/modules/views_ui/src/Tests/CustomBooleanTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views_ui\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Views;
 
 /**
@@ -103,8 +104,8 @@ public function testCustomOption() {
       $output = drupal_render($output);
 
       $replacements = array('%type' => $type);
-      $this->{$values['test']}(strpos($output, $values['true']), format_string('Expected custom boolean TRUE value in output for %type.', $replacements));
-      $this->{$values['test']}(strpos($output, $values['false']), format_string('Expected custom boolean FALSE value in output for %type', $replacements));
+      $this->{$values['test']}(strpos($output, $values['true']), SafeMarkup::format('Expected custom boolean TRUE value in output for %type.', $replacements));
+      $this->{$values['test']}(strpos($output, $values['false']), SafeMarkup::format('Expected custom boolean FALSE value in output for %type', $replacements));
     }
   }
 
diff --git a/core/modules/views_ui/src/Tests/DefaultViewsTest.php b/core/modules/views_ui/src/Tests/DefaultViewsTest.php
index 8a88e3d..344e764 100644
--- a/core/modules/views_ui/src/Tests/DefaultViewsTest.php
+++ b/core/modules/views_ui/src/Tests/DefaultViewsTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\views_ui\Tests;
+use Drupal\Component\Utility\SafeMarkup;
 
 use Drupal\Core\Url;
 use Drupal\user\Entity\Role;
@@ -216,7 +217,7 @@ function clickViewsOperationLink($label, $unique_href_part) {
         break;
       }
     }
-    $this->assertTrue(isset($index), format_string('Link to "@label" containing @part found.', array('@label' => $label, '@part' => $unique_href_part)));
+    $this->assertTrue(isset($index), SafeMarkup::format('Link to "@label" containing @part found.', array('@label' => $label, '@part' => $unique_href_part)));
     if (isset($index)) {
       return $this->clickLink($label, $index);
     }
diff --git a/core/modules/views_ui/src/Tests/DisplayAttachmentTest.php b/core/modules/views_ui/src/Tests/DisplayAttachmentTest.php
index 68fa2b3..9f3d34d 100644
--- a/core/modules/views_ui/src/Tests/DisplayAttachmentTest.php
+++ b/core/modules/views_ui/src/Tests/DisplayAttachmentTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views_ui\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Views;
 
 /**
@@ -35,7 +36,7 @@ public function testAttachmentUI() {
     $this->drupalGet($attachment_display_url);
 
     foreach (array('default', 'page-1') as $display_id) {
-      $this->assertNoFieldChecked("edit-displays-$display_id", format_string('Make sure the @display_id can be marked as attached', array('@display_id' => $display_id)));
+      $this->assertNoFieldChecked("edit-displays-$display_id", SafeMarkup::format('Make sure the @display_id can be marked as attached', array('@display_id' => $display_id)));
     }
 
     // Save the attachments and test the value on the view.
diff --git a/core/modules/views_ui/src/Tests/DisplayTest.php b/core/modules/views_ui/src/Tests/DisplayTest.php
index 1b4d04c..db61882 100644
--- a/core/modules/views_ui/src/Tests/DisplayTest.php
+++ b/core/modules/views_ui/src/Tests/DisplayTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\views_ui\Tests;
 
 use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 
 use Drupal\views\Views;
@@ -130,7 +131,7 @@ public function testDisplayAreas() {
     // Assert that the expected text is found in each area category.
     foreach ($areas as $type) {
       $element = $this->xpath('//div[contains(@class, :class)]/div', array(':class' => $type));
-      $this->assertEqual((string) $element[0], String::format('The selected display type does not use @type plugins', array('@type' => $type)));
+      $this->assertEqual((string) $element[0], SafeMarkup::format('The selected display type does not use @type plugins', array('@type' => $type)));
     }
   }
 
@@ -183,7 +184,7 @@ public function testPageContextualLinks() {
     $this->drupalGet('test-display');
     $id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1';
     // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
-    $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
+    $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', SafeMarkup::format('Contextual link placeholder with id @id exists.', array('@id' => $id)));
 
     // Get server-rendered contextual links.
     // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
diff --git a/core/modules/views_ui/src/Tests/HandlerTest.php b/core/modules/views_ui/src/Tests/HandlerTest.php
index 4c9c786..42aba92 100644
--- a/core/modules/views_ui/src/Tests/HandlerTest.php
+++ b/core/modules/views_ui/src/Tests/HandlerTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views_ui\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\views\ViewExecutable;
 
@@ -148,7 +149,7 @@ public function testBrokenHandlers() {
       $href = "admin/structure/views/nojs/handler/test_view_broken/default/$type/id_broken";
 
       $result = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
-      $this->assertEqual(count($result), 1, String::format('Handler (%type) edit link found.', array('%type' => $type)));
+      $this->assertEqual(count($result), 1, SafeMarkup::format('Handler (%type) edit link found.', array('%type' => $type)));
 
       $text = t('Broken/missing handler');
 
@@ -167,7 +168,7 @@ public function testBrokenHandlers() {
       ];
 
       foreach ($original_configuration as $key => $value) {
-        $this->assertText(String::format('@key: @value', array('@key' => $key, '@value' => $value)));
+        $this->assertText(SafeMarkup::format('@key: @value', array('@key' => $key, '@value' => $value)));
       }
     }
   }
diff --git a/core/modules/views_ui/src/Tests/StorageTest.php b/core/modules/views_ui/src/Tests/StorageTest.php
index 73fe632..2003af5 100644
--- a/core/modules/views_ui/src/Tests/StorageTest.php
+++ b/core/modules/views_ui/src/Tests/StorageTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views_ui\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\views\Views;
 
@@ -54,7 +55,7 @@ public function testDetails() {
     $view = Views::getView($view_name);
 
     foreach (array('label', 'tag', 'description', 'langcode') as $property) {
-      $this->assertEqual($view->storage->get($property), $edit[$property], format_string('Make sure the property @property got probably saved.', array('@property' => $property)));
+      $this->assertEqual($view->storage->get($property), $edit[$property], SafeMarkup::format('Make sure the property @property got probably saved.', array('@property' => $property)));
     }
   }
 
diff --git a/core/modules/views_ui/src/Tests/TagTest.php b/core/modules/views_ui/src/Tests/TagTest.php
index 673b91f..10238dd 100644
--- a/core/modules/views_ui/src/Tests/TagTest.php
+++ b/core/modules/views_ui/src/Tests/TagTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views_ui\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\views\Tests\ViewUnitTestBase;
 use Drupal\views_ui\Controller\ViewsUIController;
 
@@ -53,7 +54,7 @@ public function testViewsUiAutocompleteTag() {
     $matches = (array) json_decode($result->getContent());
     $this->assertEqual(count($matches), 8, 'Make sure that only a subset is returned.');
     foreach ($matches as $tag) {
-      $this->assertTrue(array_search($tag, $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', array('@tag' => $tag)));
+      $this->assertTrue(array_search($tag, $tags) !== FALSE, SafeMarkup::format('Make sure the returned tag @tag actually exists.', array('@tag' => $tag)));
     }
 
     // Make sure an invalid result doesn't return anything.
diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php
index 1205f28..d8fee12 100644
--- a/core/modules/views_ui/src/ViewEditForm.php
+++ b/core/modules/views_ui/src/ViewEditForm.php
@@ -8,6 +8,7 @@
 namespace Drupal\views_ui;
 
 use Drupal\Component\Utility\Html;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\UrlHelper;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Ajax\AjaxResponse;
@@ -1083,7 +1084,7 @@ public function getFormBucket(ViewUI $view, $type, $display) {
       $build['fields'][$id]['#class'][] = Html::cleanCssIdentifier($display['id']. '-' . $type . '-' . $id);
 
       if ($executable->display_handler->useGroupBy() && $handler->usesGroupBy()) {
-        $build['fields'][$id]['#settings_links'][] = $this->l(String::format('<span class="label">@text</span>', array('@text' => $this->t('Aggregation settings'))), new Url('views_ui.form_handler_group', array(
+        $build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', array('@text' => $this->t('Aggregation settings'))), new Url('views_ui.form_handler_group', array(
           'js' => 'nojs',
           'view' => $view->id(),
           'display_id' => $display['id'],
@@ -1093,7 +1094,7 @@ public function getFormBucket(ViewUI $view, $type, $display) {
       }
 
       if ($handler->hasExtraOptions()) {
-        $build['fields'][$id]['#settings_links'][] = $this->l(String::format('<span class="label">@text</span>', array('@text' => $this->t('Settings'))), new Url('views_ui.form_handler_extra', array(
+        $build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', array('@text' => $this->t('Settings'))), new Url('views_ui.form_handler_extra', array(
           'js' => 'nojs',
           'view' => $view->id(),
           'display_id' => $display['id'],
diff --git a/core/modules/views_ui/views_ui.theme.inc b/core/modules/views_ui/views_ui.theme.inc
index 2187076..b474693 100644
--- a/core/modules/views_ui/views_ui.theme.inc
+++ b/core/modules/views_ui/views_ui.theme.inc
@@ -158,7 +158,7 @@ function theme_views_ui_build_group_filter_form($variables) {
       'value' => drupal_render($form['group_items'][$group_id]['value']),
       'remove' => array(
         'data' => array(
-          '#markup' => drupal_render($form['group_items'][$group_id]['remove']) . \Drupal::l(String::format('<span>@text</span>', array('@text' => t('Remove'))), Url::fromRoute('<none>', [], array('attributes' => array('id' => 'views-remove-link-' . $group_id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item'))))),
+          '#markup' => drupal_render($form['group_items'][$group_id]['remove']) . \Drupal::l(SafeMarkup::format('<span>@text</span>', array('@text' => t('Remove'))), Url::fromRoute('<none>', [], array('attributes' => array('id' => 'views-remove-link-' . $group_id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item'))))),
         ),
       ),
     );
@@ -282,7 +282,7 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
         $remove_link = array(
           '#type' => 'link',
           '#url' => Url::fromRoute('<none>'),
-          '#title' => String::format('<span>@text</span>', array('@text' => t('Remove'))),
+          '#title' => SafeMarkup::format('<span>@text</span>', array('@text' => t('Remove'))),
           '#weight' => '1',
           '#options' => array(
             'attributes' => array(
diff --git a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
index 716059f..c784479 100644
--- a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\Tests\Component\Utility;
 
 use Drupal\Component\Utility\Random;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Tests\UnitTestCase;
 
@@ -39,7 +40,7 @@ public function testRandomStringUniqueness() {
     $random = new Random();
     for ($i = 0; $i <= 50; $i++) {
       $str = $random->string(1, TRUE);
-      $this->assertFalse(isset($strings[$str]), String::format('Generated duplicate random string !string', array('!string' => $str)));
+      $this->assertFalse(isset($strings[$str]), SafeMarkup::format('Generated duplicate random string !string', array('!string' => $str)));
       $strings[$str] = TRUE;
     }
   }
@@ -54,7 +55,7 @@ public function testRandomNamesUniqueness() {
     $random = new Random();
     for ($i = 0; $i <= 10; $i++) {
       $str = $random->name(1, TRUE);
-      $this->assertFalse(isset($names[$str]), String::format('Generated duplicate random name !name', array('!name' => $str)));
+      $this->assertFalse(isset($names[$str]), SafeMarkup::format('Generated duplicate random name !name', array('!name' => $str)));
       $names[$str] = TRUE;
     }
   }
diff --git a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
index 9480a7e..3113819 100644
--- a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Tests\Component\Utility;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\UrlHelper;
 use Drupal\Component\Utility\String;
 use Drupal\Tests\UnitTestCase;
@@ -94,7 +95,7 @@ public function providerTestValidAbsoluteData() {
   public function testValidAbsolute($url, $scheme) {
     $test_url = $scheme . '://' . $url;
     $valid_url = UrlHelper::isValid($test_url, TRUE);
-    $this->assertTrue($valid_url, String::format('@url is a valid URL.', array('@url' => $test_url)));
+    $this->assertTrue($valid_url, SafeMarkup::format('@url is a valid URL.', array('@url' => $test_url)));
   }
 
   /**
@@ -125,7 +126,7 @@ public function providerTestInvalidAbsolute() {
   public function testInvalidAbsolute($url, $scheme) {
     $test_url = $scheme . '://' . $url;
     $valid_url = UrlHelper::isValid($test_url, TRUE);
-    $this->assertFalse($valid_url, String::format('@url is NOT a valid URL.', array('@url' => $test_url)));
+    $this->assertFalse($valid_url, SafeMarkup::format('@url is NOT a valid URL.', array('@url' => $test_url)));
   }
 
   /**
@@ -159,7 +160,7 @@ public function providerTestValidRelativeData() {
   public function testValidRelative($url, $prefix) {
     $test_url = $prefix . $url;
     $valid_url = UrlHelper::isValid($test_url);
-    $this->assertTrue($valid_url, String::format('@url is a valid URL.', array('@url' => $test_url)));
+    $this->assertTrue($valid_url, SafeMarkup::format('@url is a valid URL.', array('@url' => $test_url)));
   }
 
   /**
@@ -190,7 +191,7 @@ public function providerTestInvalidRelativeData() {
   public function testInvalidRelative($url, $prefix) {
     $test_url = $prefix . $url;
     $valid_url = UrlHelper::isValid($test_url);
-    $this->assertFalse($valid_url, String::format('@url is NOT a valid URL.', array('@url' => $test_url)));
+    $this->assertFalse($valid_url, SafeMarkup::format('@url is NOT a valid URL.', array('@url' => $test_url)));
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
index 936287a..e248ad0 100644
--- a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Tests\Core\Config;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Drupal\Tests\UnitTestCase;
 use Drupal\Core\Config\Config;
@@ -413,14 +414,14 @@ public function validateNameProvider() {
       // Name missing namespace (dot).
       array(
         'MissingNamespace',
-        String::format('Missing namespace in Config object name MissingNamespace.', array(
+        SafeMarkup::format('Missing namespace in Config object name MissingNamespace.', array(
           '@name' => 'MissingNamespace',
         )),
       ),
       // Exceeds length (max length plus an extra dot).
       array(
         str_repeat('a', Config::MAX_NAME_LENGTH) . ".",
-        String::format('Config object name @name exceeds maximum allowed length of @length characters.', array(
+        SafeMarkup::format('Config object name @name exceeds maximum allowed length of @length characters.', array(
           '@name' => str_repeat('a', Config::MAX_NAME_LENGTH) . ".",
           '@length' => Config::MAX_NAME_LENGTH,
         )),
@@ -431,7 +432,7 @@ public function validateNameProvider() {
       $name = 'name.' . $char;
       $return[] = array(
         $name,
-        String::format('Invalid character in Config object name @name.', array(
+        SafeMarkup::format('Invalid character in Config object name @name.', array(
           '@name' => $name,
         )),
       );
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php
index d3dfc25..e3950cc 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Tests\Core\Config\Entity;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Tests\UnitTestCase;
 use Drupal\Core\Config\Entity\ConfigEntityType;
 use Drupal\Component\Utility\String;
@@ -50,7 +51,7 @@ public function testConfigPrefixLengthExceeds() {
       'config_prefix' => $this->randomMachineName(59),
     );
     $config_entity = $this->setUpConfigEntityType($definition);
-    $this->setExpectedException('\Drupal\Core\Config\ConfigPrefixLengthException', String::format($message_text, array(
+    $this->setExpectedException('\Drupal\Core\Config\ConfigPrefixLengthException', SafeMarkup::format($message_text, array(
       '@config_prefix' => $definition['provider'] . '.' . $definition['config_prefix'],
       '@max_char' => ConfigEntityType::PREFIX_LENGTH,
     )));
diff --git a/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php b/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php
index b153d9f..fac7b1f 100644
--- a/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php
+++ b/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Tests\Core\Controller;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Controller\TitleResolver;
 use Drupal\Tests\UnitTestCase;
@@ -151,7 +152,7 @@ class TitleCallback {
    *   Returns the example string.
    */
   public function example($value) {
-    return String::format('test @value', array('@value' => $value));
+    return SafeMarkup::format('test @value', array('@value' => $value));
   }
 
 }
diff --git a/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php b/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php
index cc49c2c..343844a 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Tests\Core\Form;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Form\FormState;
 use Drupal\Tests\UnitTestCase;
@@ -477,7 +478,7 @@ public function providerTestPerformRequiredValidation() {
           '#maxlength' => 7,
           '#value' => $this->randomMachineName(8),
         ),
-        String::format('!name cannot be longer than %max characters but is currently %length characters long.', array('!name' => 'Test', '%max' => '7', '%length' => 8)),
+        SafeMarkup::format('!name cannot be longer than %max characters but is currently %length characters long.', array('!name' => 'Test', '%max' => '7', '%length' => 8)),
         FALSE,
       ),
     );
diff --git a/core/tests/Drupal/Tests/Core/Logger/LogMessageParserTest.php b/core/tests/Drupal/Tests/Core/Logger/LogMessageParserTest.php
index f361456..4f99423 100644
--- a/core/tests/Drupal/Tests/Core/Logger/LogMessageParserTest.php
+++ b/core/tests/Drupal/Tests/Core/Logger/LogMessageParserTest.php
@@ -54,12 +54,13 @@ public function providerTestParseMessagePlaceholders() {
         array('message' => 'User {username} created', 'context' => array('username' => 'Dries')),
         array('message' => 'User @username created', 'context' => array('@username' => 'Dries')),
       ),
-      // PSR3 style mixed in a format_string style message.
+      // PSR3 style mixed in a \Drupal\Component\Utility\SafeMarkup::format style
+      // message.
       array(
         array('message' => 'User {username} created @time', 'context' => array('username' => 'Dries', '@time' => 'now')),
         array('message' => 'User @username created @time', 'context' => array('@username' => 'Dries', '@time' => 'now')),
       ),
-      // format_string style message only.
+      // \Drupal\Component\Utility\SafeMarkup::format style message only.
       array(
         array('message' => 'User @username created', 'context' => array('@username' => 'Dries')),
         array('message' => 'User @username created', 'context' => array('@username' => 'Dries')),
diff --git a/core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php b/core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php
index 01c6ab9..357f677 100644
--- a/core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php
+++ b/core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Tests\Core\Path;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Path\PathMatcher;
 use Drupal\Tests\UnitTestCase;
@@ -49,7 +50,7 @@ protected function setUp() {
   public function testMatchPath($patterns, $paths) {
     foreach ($paths as $path => $expected_result) {
       $actual_result = $this->pathMatcher->matchPath($path, $patterns);
-      $this->assertEquals($actual_result, $expected_result, String::format('Tried matching the path <code>@path</code> to the pattern <pre>@patterns</pre> - expected @expected, got @actual.', array(
+      $this->assertEquals($actual_result, $expected_result, SafeMarkup::format('Tried matching the path <code>@path</code> to the pattern <pre>@patterns</pre> - expected @expected, got @actual.', array(
         '@path' => $path,
         '@patterns' => $patterns,
         '@expected' => var_export($expected_result, TRUE),
diff --git a/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php b/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php
index 44d5d95..f952a52 100644
--- a/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php
+++ b/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\Tests\Core\Transliteration;
 
 use Drupal\Component\Utility\Random;
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Transliteration\PhpTransliteration;
 use Drupal\Tests\UnitTestCase;
@@ -59,7 +60,7 @@ public function testPhpTransliterationWithAlter($langcode, $original, $expected,
     $transliteration = new PhpTransliteration(NULL, $module_handler);
 
     $actual = $transliteration->transliterate($original, $langcode);
-    $this->assertSame($expected, $actual, String::format('@original transliteration to @actual is identical to @expected for language @langcode in service instance.', array(
+    $this->assertSame($expected, $actual, SafeMarkup::format('@original transliteration to @actual is identical to @expected for language @langcode in service instance.', array(
       '@original' => $printable,
       '@langcode' => $langcode,
       '@expected' => $expected,
diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php
index e82c3a9..c15bff2 100644
--- a/core/tests/Drupal/Tests/UnitTestCase.php
+++ b/core/tests/Drupal/Tests/UnitTestCase.php
@@ -202,7 +202,7 @@ public function getStringTranslationStub() {
     $translation = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
     $translation->expects($this->any())
       ->method('translate')
-      ->will($this->returnCallback('Drupal\Component\Utility\String::format'));
+      ->will($this->returnCallback('Drupal\Component\Utility\SafeMarkup::format'));
     return $translation;
   }
 
