diff --git a/src/TwigComponent/src/Twig/TwigPreLexer.php b/src/TwigComponent/src/Twig/TwigPreLexer.php index cc28a9e28cc..2900c2a65a9 100644 --- a/src/TwigComponent/src/Twig/TwigPreLexer.php +++ b/src/TwigComponent/src/Twig/TwigPreLexer.php @@ -123,7 +123,7 @@ public function preLexComponents(string $input): string private function consumeComponentName(string $customExceptionMessage = null): string { $start = $this->position; - while ($this->position < $this->length && preg_match('/[A-Za-z0-9_:@\-\/.]/', $this->input[$this->position])) { + while ($this->position < $this->length && preg_match('/[A-Za-z0-9_:@\-.]/', $this->input[$this->position])) { ++$this->position; } diff --git a/src/TwigComponent/tests/Unit/TwigPreLexerTest.php b/src/TwigComponent/tests/Unit/TwigPreLexerTest.php index 8220d29f96a..5fb6f9174b8 100644 --- a/src/TwigComponent/tests/Unit/TwigPreLexerTest.php +++ b/src/TwigComponent/tests/Unit/TwigPreLexerTest.php @@ -62,6 +62,11 @@ public function getLexTests(): iterable '{{ component(\'foo\', { bar: true }) }}', ]; + yield 'attribute_with_no_value_and_no_attributes' => [ + '', + '{{ component(\'foo\') }}', + ]; + yield 'component_with_default_block_content' => [ 'Foo', '{% component \'foo\' %}{% block content %}Foo{% endblock %}{% endcomponent %}', @@ -83,10 +88,6 @@ public function getLexTests(): iterable '', '{% component \'foo-bar\' %}{% endcomponent %}', ]; - yield 'component_with_character_/_on_his_name' => [ - '', - '{% component \'foo/bar\' %}{% endcomponent %}', - ]; yield 'component_with_character_._on_his_name' => [ '', '{% component \'foo.bar\' %}{% endcomponent %}',