From e41e05fcbec6eca184cf9efee6c9557f7e1485e3 Mon Sep 17 00:00:00 2001 From: Basanta Tajpuriya <38497591+basantashubhu@users.noreply.github.com> Date: Thu, 18 Dec 2025 23:02:55 +0545 Subject: [PATCH 1/5] fix escaping of AppendableAttributeValue --- src/Illuminate/View/ComponentAttributeBag.php | 4 ++++ tests/View/ViewComponentAttributeBagTest.php | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index 607f4d134301..7057cf629242 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -278,6 +278,10 @@ protected function shouldEscapeAttributeValue($escape, $value) return false; } + if ($value instanceof AppendableAttributeValue) { + return $this->shouldEscapeAttributeValue($escape, $value->value); + } + return ! is_object($value) && ! is_null($value) && ! is_bool($value); diff --git a/tests/View/ViewComponentAttributeBagTest.php b/tests/View/ViewComponentAttributeBagTest.php index a2293e6e5f19..980b1d7b22b7 100644 --- a/tests/View/ViewComponentAttributeBagTest.php +++ b/tests/View/ViewComponentAttributeBagTest.php @@ -63,6 +63,19 @@ public function testAttributeRetrieval() $this->assertSame('test-escaped="<tag attr="attr">"', (string) $bag); + $bag = (new ComponentAttributeBag) + ->merge([ + 'data-bs-tooltip' => new AppendableAttributeValue('Sample Title'), + ]); + + $this->assertSame('data-bs-tooltip="<strong>Sample Title</strong>"', (string) $bag); + + $bag->merge([ + 'data-bs-tooltip' => new AppendableAttributeValue('First Text'), + ]); + + $this->assertSame('data-bs-tooltip="<em>First Text</em> <strong>Sample Title</strong>"', (string) $bag); + $bag = (new ComponentAttributeBag) ->merge([ 'test-string' => 'ok', From ce40bcd4196e78a501fafd82c0be1e17b5ce6d18 Mon Sep 17 00:00:00 2001 From: Basanta Tajpuriya <38497591+basantashubhu@users.noreply.github.com> Date: Thu, 18 Dec 2025 23:33:35 +0545 Subject: [PATCH 2/5] use class AppendableAttributeValue --- tests/View/ViewComponentAttributeBagTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/View/ViewComponentAttributeBagTest.php b/tests/View/ViewComponentAttributeBagTest.php index 980b1d7b22b7..fc0bd401c084 100644 --- a/tests/View/ViewComponentAttributeBagTest.php +++ b/tests/View/ViewComponentAttributeBagTest.php @@ -3,6 +3,7 @@ namespace Illuminate\Tests\View; use Illuminate\View\ComponentAttributeBag; +use Illuminate\View\AppendableAttributeValue; use PHPUnit\Framework\TestCase; class ViewComponentAttributeBagTest extends TestCase From 5875519608f92cbcf54a5fd472e1d7314e45a6c0 Mon Sep 17 00:00:00 2001 From: Basanta Tajpuriya <38497591+basantashubhu@users.noreply.github.com> Date: Thu, 18 Dec 2025 23:35:53 +0545 Subject: [PATCH 3/5] Reorder use statements in ViewComponentAttributeBagTest --- tests/View/ViewComponentAttributeBagTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/View/ViewComponentAttributeBagTest.php b/tests/View/ViewComponentAttributeBagTest.php index fc0bd401c084..c4b39851d465 100644 --- a/tests/View/ViewComponentAttributeBagTest.php +++ b/tests/View/ViewComponentAttributeBagTest.php @@ -2,8 +2,8 @@ namespace Illuminate\Tests\View; -use Illuminate\View\ComponentAttributeBag; use Illuminate\View\AppendableAttributeValue; +use Illuminate\View\ComponentAttributeBag; use PHPUnit\Framework\TestCase; class ViewComponentAttributeBagTest extends TestCase From ee1a915217f6297f7049565b00dfe97d9d1c5cfb Mon Sep 17 00:00:00 2001 From: Basanta Tajpuriya <38497591+basantashubhu@users.noreply.github.com> Date: Thu, 18 Dec 2025 23:36:32 +0545 Subject: [PATCH 4/5] Fix formatting in ComponentAttributeBag.php --- src/Illuminate/View/ComponentAttributeBag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index 7057cf629242..ea2d67d4d53c 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -281,7 +281,7 @@ protected function shouldEscapeAttributeValue($escape, $value) if ($value instanceof AppendableAttributeValue) { return $this->shouldEscapeAttributeValue($escape, $value->value); } - + return ! is_object($value) && ! is_null($value) && ! is_bool($value); From 5bc2f16a4c1021367ea83257ad0c973dc86b22ff Mon Sep 17 00:00:00 2001 From: Basanta Tajpuriya <38497591+basantashubhu@users.noreply.github.com> Date: Thu, 18 Dec 2025 23:51:17 +0545 Subject: [PATCH 5/5] Fix merge method usage in ViewComponentAttributeBagTest --- tests/View/ViewComponentAttributeBagTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/View/ViewComponentAttributeBagTest.php b/tests/View/ViewComponentAttributeBagTest.php index c4b39851d465..2cb054992df2 100644 --- a/tests/View/ViewComponentAttributeBagTest.php +++ b/tests/View/ViewComponentAttributeBagTest.php @@ -71,7 +71,7 @@ public function testAttributeRetrieval() $this->assertSame('data-bs-tooltip="<strong>Sample Title</strong>"', (string) $bag); - $bag->merge([ + $bag = $bag->merge([ 'data-bs-tooltip' => new AppendableAttributeValue('First Text'), ]);