Skip to content
Snippets Groups Projects
Commit c0a194b9 authored by catch's avatar catch
Browse files

Issue #3457168 by raphaelbertrand, gauravvvv, bbrala, longwave: Since...

Issue #3457168 by raphaelbertrand, gauravvvv, bbrala, longwave: Since twig/twig 3.9: error with "twig_escape_filter" function usage in /core/lib/Drupal/Core/Template/TwigExtension.php

(cherry picked from commit 128310c8)
parent 8db24ab8
Branches
Tags
15 merge requests!10663Issue #3495778: Update phpdoc in FileSaveHtaccessLoggingTest,!10451Issue #3472458 by watergate, smustgrave: CKEditor 5 show blocks label is not translated,!103032838547 Fix punctuation rules for inline label suffix colon with CSS only,!10150Issue #3467294 by quietone, nod_, smustgrave, catch, longwave: Change string...,!10130Resolve #3480321 "Second level menu",!9936Issue #3483087: Check the module:// prefix in the translation server path and replace it with the actual module path,!9933Issue #3394728 by ankondrat4: Undefined array key "#prefix" and deprecated function: explode() in Drupal\file\Element\ManagedFile::uploadAjaxCallback(),!9914Issue #3451136 by quietone, gapple, ghost of drupal past: Improve...,!9882Draft: Issue #3481777 In bulk_form ensure the triggering element is the bulk_form button,!9839Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9815Issue #3480025: There is no way to remove entity cache items,!9757Issue #3478869 Add "All" or overview links to parent links,!9752Issue #3439910 by pooja_sharma, vensires: Fix Toolbar tests that rely on UID1's super user behavior,!9749Issue #3439910 by pooja_sharma, vensires: Fix Toolbar tests that rely on UID1's super user behavior,!9678Issue #3465132 by catch, Spokje, nod_: Show test run time by class in run-tests.sh output
Pipeline #295252 canceled
......@@ -23,6 +23,7 @@
use Twig\Node\Node;
use Twig\TwigFilter;
use Twig\TwigFunction;
use Twig\Runtime\EscaperRuntime;
/**
* A class providing Drupal Twig extensions.
......@@ -461,7 +462,7 @@ public function escapeFilter(Environment $env, $arg, $strategy = 'html', $charse
if ($strategy == 'html') {
return Html::escape($return);
}
return twig_escape_filter($env, $return, $strategy, $charset, $autoescape);
return $env->getRuntime(EscaperRuntime::class)->escape($arg, $strategy, $charset, $autoescape);
}
// This is a normal render array, which is safe by definition, with
......
......@@ -126,4 +126,17 @@ public function testDump(): void {
}
/**
* Test if Drupal html strategy is done and the fallback to Twig itself works.
*/
public function testRenderStrategies(): void {
/** @var \Drupal\Core\Template\TwigExtension $extension */
$extension = \Drupal::service('twig.extension');
/** @var \Drupal\Core\Template\TwigEnvironment $twig */
$twig = \Drupal::service('twig');
$this->assertSame('test&', $extension->escapeFilter($twig, 'test&'), 'TwigExtension::escapeFilter() renders escaped & when strategy is html (default).');
$this->assertSame('test\u0026', $extension->escapeFilter($twig, 'test&', 'js'), 'TwigExtension::escapeFilter() renders escaped & when strategy is js.');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment