diff --git a/core/lib/Drupal/Core/CoreServiceProvider.php b/core/lib/Drupal/Core/CoreServiceProvider.php index 8a525c9..7d581fc 100644 --- a/core/lib/Drupal/Core/CoreServiceProvider.php +++ b/core/lib/Drupal/Core/CoreServiceProvider.php @@ -121,9 +121,7 @@ public static function registerTwig(ContainerBuilder $container) { // files folder is writable. 'cache' => drupal_installation_attempted() ? FALSE : settings()->get('twig_cache', TRUE), 'base_template_class' => 'Drupal\Core\Template\TwigTemplate', - // @todo Remove in followup issue - // @see http://drupal.org/node/1712444. - 'autoescape' => FALSE, + 'autoescape' => TRUE, // @todo Remove in followup issue // @see http://drupal.org/node/1806538. 'strict_variables' => FALSE, diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine index e09ec99..b46ddb5 100644 --- a/core/themes/engines/twig/twig.engine +++ b/core/themes/engines/twig/twig.engine @@ -110,7 +110,7 @@ function twig_render_var($arg) { return NULL; } - // Keep Twig_Markup objects intact to prepare for later autoescaping support + // Keep Twig_Markup objects intact to support autoescaping. if ($arg instanceOf Twig_Markup) { return $arg; } @@ -121,13 +121,13 @@ function twig_render_var($arg) { if (is_object($arg)) { if (method_exists($arg, '__toString')) { - return (string) $arg; + return new Twig_Markup((string) $arg, 'UTF-8'); } throw new Exception(t('Object of type "@class" cannot be printed.', array('@class' => get_class($arg)))); } // This is a normal render array. - return render($arg); + return new Twig_Markup(render($arg), 'UTF-8'); } /**