diff --git a/core/lib/Drupal/Component/Utility/String.php b/core/lib/Drupal/Component/Utility/String.php
index 970436c..e710486 100644
--- a/core/lib/Drupal/Component/Utility/String.php
+++ b/core/lib/Drupal/Component/Utility/String.php
@@ -96,6 +96,8 @@ public static function decodeEntities($text) {
    * @see t()
    */
   public static function format($string, array $args = array()) {
+    $safe = TRUE;
+
     // Transform arguments before inserting them.
     foreach ($args as $key => $value) {
       switch ($key[0]) {
@@ -112,9 +114,18 @@ public static function format($string, array $args = array()) {
 
         case '!':
           // Pass-through.
+          if (!SafeMarkup::isSafe($args[$key])) {
+            $safe = FALSE;
+          }
       }
     }
-    return SafeMarkup::set(strtr($string, $args));
+
+    $output = strtr($string, $args);
+    if ($safe) {
+      SafeMarkup::set($output);
+    }
+
+    return $output;
   }
 
   /**
