diff --git a/src/LiveComponent/src/Util/LiveAttributesCollection.php b/src/LiveComponent/src/Util/LiveAttributesCollection.php index 7c99a19f8e7..8f704689554 100644 --- a/src/LiveComponent/src/Util/LiveAttributesCollection.php +++ b/src/LiveComponent/src/Util/LiveAttributesCollection.php @@ -12,6 +12,7 @@ namespace Symfony\UX\LiveComponent\Util; use Twig\Environment; +use Twig\Extension\EscaperExtension; /** * An array of attributes that can eventually be returned as an escaped array. @@ -99,6 +100,8 @@ public function setBrowserEventsToDispatch(array $browserEventsToDispatch): void private function escapeAttribute(string $value): string { - return twig_escape_filter($this->twig, $value, 'html_attr'); + $escapeExtension = new EscaperExtension(); + + return (string) $escapeExtension->escape($this->twig, $value, 'html_attr'); } } diff --git a/src/StimulusBundle/src/Dto/StimulusAttributes.php b/src/StimulusBundle/src/Dto/StimulusAttributes.php index fe0b76929ae..908bab4b146 100644 --- a/src/StimulusBundle/src/Dto/StimulusAttributes.php +++ b/src/StimulusBundle/src/Dto/StimulusAttributes.php @@ -14,6 +14,7 @@ namespace Symfony\UX\StimulusBundle\Dto; use Twig\Environment; +use Twig\Extension\EscaperExtension; /** * Helper to build Stimulus-related HTML attributes. @@ -214,7 +215,9 @@ private function getFormattedValue(mixed $value): string private function escapeAsHtmlAttr(mixed $value): string { - return (string) twig_escape_filter($this->env, $value, 'html_attr'); + $escapeExtension = new EscaperExtension(); + + return (string) $escapeExtension->escape($this->env, $value, 'html_attr'); } /**