diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 4d441f2..ae8e00b 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1078,7 +1078,10 @@ function template_preprocess_item_list(&$variables) {
  *   - title: A descriptive title of the feed.
  */
 function template_preprocess_feed_icon(&$variables) {
-  $text = t('Subscribe to !feed-title', array('!feed-title' => $variables['title']));
+  // Stripping tags because that's what l() used to do.
+  $title = strip_tags($variables['title']);
+  $text = t('Subscribe to @feed-title', array('@feed-title' => $title));
+  $variables['attributes']['title'] = $text;
   $variables['icon'] = array(
     '#theme' => 'image__feed_icon',
     '#uri' => 'core/misc/feed.png',
@@ -1086,8 +1089,6 @@ function template_preprocess_feed_icon(&$variables) {
     '#height' => 16,
     '#alt' => $text,
   );
-  // Stripping tags because that's what l() used to do.
-  $variables['attributes']['title'] = strip_tags($text);
 }
 
 /**
diff --git a/core/lib/Drupal/Core/Template/AttributeString.php b/core/lib/Drupal/Core/Template/AttributeString.php
index 2dff59b..f6693b0 100644
--- a/core/lib/Drupal/Core/Template/AttributeString.php
+++ b/core/lib/Drupal/Core/Template/AttributeString.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\Core\Template;
 
+use Drupal\Component\Utility\SafeMarkup;
+
 /**
  * A class that represents most standard HTML attributes.
  *
@@ -28,7 +30,12 @@ class AttributeString extends AttributeValueBase {
    * Implements the magic __toString() method.
    */
   public function __toString() {
-    return htmlspecialchars($this->value, ENT_QUOTES, 'UTF-8');
+    if (SafeMarkup::isSafe($this->value)) {
+      return $this->value;
+    }
+    else {
+      return htmlspecialchars($this->value, ENT_QUOTES, 'UTF-8');
+    }
   }
 
 }
diff --git a/core/lib/Drupal/Core/Template/AttributeValueBase.php b/core/lib/Drupal/Core/Template/AttributeValueBase.php
index c037004..11cb3c6 100644
--- a/core/lib/Drupal/Core/Template/AttributeValueBase.php
+++ b/core/lib/Drupal/Core/Template/AttributeValueBase.php
@@ -7,12 +7,14 @@
 
 namespace Drupal\Core\Template;
 
+use Drupal\Component\Utility\SafeStringInterface;
+
 /**
  * Defines the base class for an attribute type.
  *
  * @see \Drupal\Core\Template\Attribute
  */
-abstract class AttributeValueBase {
+abstract class AttributeValueBase implements SafeStringInterface {
 
   /**
    * Renders '$name=""' if $value is an empty string.
