diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 79f7107..f06c058 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1878,6 +1878,9 @@ function template_preprocess_page(&$variables) {
 
   // Move some variables to the top level for themer convenience and template cleanliness.
   $variables['show_messages'] = $variables['page']['#show_messages'];
+  $variables['title_escaped'] = new RenderWrapper(function (&$title) {
+    return Xss::filterAdmin($title);
+  }, array(&$variables['title']));
   $variables['title'] = $variables['page']['#title'];
 
   foreach (system_region_list(\Drupal::theme()->getActiveTheme()->getName()) as $region_key => $region_name) {
diff --git a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
index 4915c16..8dfd0fc 100644
--- a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
+++ b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
@@ -22,6 +22,9 @@ class TwigNodeVisitor implements \Twig_NodeVisitorInterface {
    * {@inheritdoc}
    */
   function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
+    if ($node instanceof \Twig_Node_Module) {
+      $this->templateName = basename($node->getAttribute('filename'));
+    }
     return $node;
   }
 
@@ -39,6 +42,10 @@ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
       }
       $class = get_class($node);
       $line = $node->getLine();
+      $expr = $node->getNode('expr');
+      if ($this->templateName == 'page.html.twig' && $expr->hasAttribute('name') && $expr->getAttribute('name') == 'title') {
+        $expr->setAttribute('name', 'title_escaped');
+      }
       return new $class(
         new \Twig_Node_Expression_Function('render_var', new \Twig_Node(array($node->getNode('expr'))), $line),
         $line
