diff --git a/core/lib/Drupal/Component/Utility/PlaceholderTrait.php b/core/lib/Drupal/Component/Utility/PlaceholderTrait.php
index f5bcb39..ce49f8a 100644
--- a/core/lib/Drupal/Component/Utility/PlaceholderTrait.php
+++ b/core/lib/Drupal/Component/Utility/PlaceholderTrait.php
@@ -84,7 +84,6 @@ protected static function placeholderFormat($string, array $args, &$safe = TRUE)
           break;
 
         case '%':
-        default:
           // Escaped and placeholder.
           if (!SafeMarkup::isSafe($value)) {
             $value = Html::escape($value);
@@ -105,6 +104,11 @@ protected static function placeholderFormat($string, array $args, &$safe = TRUE)
           if (!SafeMarkup::isSafe($value)) {
             $safe = FALSE;
           }
+          break;
+
+        default:
+          throw new \InvalidArgumentException('Invalid placeholder');
+          break;
       }
     }
     return strtr($string, $args);
diff --git a/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php b/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
index 12f2012..9468fe7 100644
--- a/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
@@ -192,6 +192,18 @@ function providerCheckPlain() {
   }
 
   /**
+   * String formatting with SafeMarkup::format() and an unsupported placeholder.
+   *
+   * When you call SafeMarkup::format() with an unsupported placeholder, an
+   * InvalidArgumentException should be thrown.
+   *
+   * @expectedException \InvalidArgumentException
+   */
+  public function testUnexpectedFormat() {
+    SafeMarkup::format('Broken placeholder: ~placeholder', ['~placeholder' => 'broken'])->__toString();
+  }
+
+  /**
    * Tests string formatting with SafeMarkup::format().
    *
    * @dataProvider providerFormat
