diff --git a/core/lib/Drupal/Component/Utility/Xss.php b/core/lib/Drupal/Component/Utility/Xss.php
index 7a77182..a9b5f6c 100644
--- a/core/lib/Drupal/Component/Utility/Xss.php
+++ b/core/lib/Drupal/Component/Utility/Xss.php
@@ -245,7 +245,7 @@ protected static function attributes($attributes) {
         case 2:
           // Attribute value, a URL after href= for instance.
           if (preg_match('/^"([^"]*)"(\s+|$)/', $attributes, $match)) {
-            $thisval = UrlHelper::filterBadProtocol($match[1]);
+            $thisval = static::filterAttributeValue($attribute_name, $match[1]);
 
             if (!$skip) {
               $attributes_array[] = "$attribute_name=\"$thisval\"";
@@ -257,7 +257,7 @@ protected static function attributes($attributes) {
           }
 
           if (preg_match("/^'([^']*)'(\s+|$)/", $attributes, $match)) {
-            $thisval = UrlHelper::filterBadProtocol($match[1]);
+            $thisval = static::filterAttributeValue($attribute_name, $match[1]);
 
             if (!$skip) {
               $attributes_array[] = "$attribute_name='$thisval'";
@@ -268,7 +268,7 @@ protected static function attributes($attributes) {
           }
 
           if (preg_match("%^([^\s\"']+)(\s+|$)%", $attributes, $match)) {
-            $thisval = UrlHelper::filterBadProtocol($match[1]);
+            $thisval = static::filterAttributeValue($attribute_name, $match[1]);
 
             if (!$skip) {
               $attributes_array[] = "$attribute_name=\"$thisval\"";
@@ -303,4 +303,25 @@ protected static function attributes($attributes) {
     return $attributes_array;
   }
 
+  /**
+   * Filters an html attribute value
+   *
+   * @param string $name
+   *   The html attribute name.
+   * @param string $value
+   *   The html attribute value.
+   *
+   * @return string
+   *   The filtered html attribute value.
+   */
+  public static function filterAttributeValue($name, $value) {
+    if (strpos($name, 'data-') === 0) {
+      // Data attributes should be left unmodified.
+      return $value;
+    }
+    else {
+      return UrlHelper::filterBadProtocol($value);
+    }
+  }
+
 }
