diff --git a/core/lib/Drupal/Component/Utility/Html.php b/core/lib/Drupal/Component/Utility/Html.php
index b6eb649..aa61121 100644
--- a/core/lib/Drupal/Component/Utility/Html.php
+++ b/core/lib/Drupal/Component/Utility/Html.php
@@ -226,6 +226,28 @@ public static function normalize($html) {
     return static::serialize($document);
   }
 
+
+  /**
+   * Strips tags and their content from html.
+   *
+   * @param string $html
+   *   The input html.
+   * @param array $tags
+   *   Tags to be removed along with their content.
+   *
+   * @return string
+   *   The modified HTML.
+   */
+  public static function stripTagContent($html, array $tags = ['style', 'script']) {
+    $dom = static::load($html);
+    foreach ($tags as $tag) {
+      foreach ($dom->getElementsByTagName($tag) as $node) {
+        $node->parentNode->removeChild($node);
+      }
+    }
+    return $dom->saveHTML();
+  }
+
   /**
    * Parses an HTML snippet and returns it as a DOM object.
    *
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 400d6cc..de25e48 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -453,6 +453,7 @@ function template_preprocess_filter_tips(&$variables) {
  * Provides filtering of input into accepted HTML.
  */
 function _filter_html($text, $filter) {
+  $text = Html::stripTagContent($text);
   $allowed_tags = preg_split('/\s+|<|>/', $filter->settings['allowed_html'], -1, PREG_SPLIT_NO_EMPTY);
   $text = Xss::filter($text, $allowed_tags);
 
