From dc992f76f423a39f37ea1cced5bd6fa456b70f02 Mon Sep 17 00:00:00 2001 From: Sebastian Klaus <30407863+klausi85@users.noreply.github.com> Date: Thu, 12 Jun 2025 08:16:03 +0200 Subject: [PATCH] [TwigComponent] Fix escaping of Alpine.js attribute keys containing numeric characters --- src/TwigComponent/src/ComponentAttributes.php | 2 +- src/TwigComponent/tests/Unit/ComponentAttributesTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TwigComponent/src/ComponentAttributes.php b/src/TwigComponent/src/ComponentAttributes.php index 82f9a5cdd41..bd4029145e2 100644 --- a/src/TwigComponent/src/ComponentAttributes.php +++ b/src/TwigComponent/src/ComponentAttributes.php @@ -80,7 +80,7 @@ public function __toString(): string // xml:*, xmlns:*, // - special syntax names (Vue.js, Svelte, Alpine.js, ...) // v-*, x-*, @*, :* - if (!ctype_alpha(str_replace(['-', '_', ':', '@', '.'], '', $key))) { + if (!ctype_alnum(str_replace(['-', '_', ':', '@', '.'], '', $key))) { $key = (string) $this->escaper->escape($key, 'html_attr'); } diff --git a/src/TwigComponent/tests/Unit/ComponentAttributesTest.php b/src/TwigComponent/tests/Unit/ComponentAttributesTest.php index 377822c3118..255364ca48e 100644 --- a/src/TwigComponent/tests/Unit/ComponentAttributesTest.php +++ b/src/TwigComponent/tests/Unit/ComponentAttributesTest.php @@ -324,6 +324,7 @@ public static function provideSpecialSyntaxAttributeNames(): iterable yield ['@click']; // Alpine.js yield ['x-on:click']; + yield ['@input.debounce.500ms']; } public function testThrowsTypeErrorWithoutEscaperRuntime(): void