From 96a5c1c80e49e800716ba97becf574de0505a69f Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Thu, 19 Mar 2026 11:57:51 +0000 Subject: [PATCH 1/5] case insensitive replacement of `assertSame('<?php echo "test"; ?>', StringUtilities::sanitizePhp('')); + $this->assertSame('<?php echo "test"; ?>', StringUtilities::sanitizePhp('')); + $this->assertSame('<?php echo "test"; ?>', StringUtilities::sanitizePhp('')); + $this->assertSame('<?php echo "test"; ?>', StringUtilities::sanitizePhp('')); + } } From ca0983104895300ff8b81daab95c49e1c976ed6b Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Thu, 19 Mar 2026 11:58:01 +0000 Subject: [PATCH 2/5] short echo tags --- src/View/Antlers/Language/Utilities/StringUtilities.php | 4 ++++ tests/Antlers/Runtime/PhpEnabledTest.php | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/View/Antlers/Language/Utilities/StringUtilities.php b/src/View/Antlers/Language/Utilities/StringUtilities.php index 134b59d44e2..38f8a6afcab 100644 --- a/src/View/Antlers/Language/Utilities/StringUtilities.php +++ b/src/View/Antlers/Language/Utilities/StringUtilities.php @@ -81,6 +81,10 @@ public static function sanitizePhp($text) { $text = str_ireplace('assertSame('<?php echo "test"; ?>', StringUtilities::sanitizePhp('')); $this->assertSame('<?php echo "test"; ?>', StringUtilities::sanitizePhp('')); } + + public function test_sanitize_php_handles_short_echo_tag() + { + $this->assertSame('<?= $var ?>', StringUtilities::sanitizePhp('')); + $this->assertSame('<?="test"?>', StringUtilities::sanitizePhp('')); + } } From 3543fda0f5aba7a8a36a9ac8015bebd3ff33a3bb Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Thu, 19 Mar 2026 17:06:27 +0000 Subject: [PATCH 3/5] wip --- .../Language/Utilities/StringUtilities.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/View/Antlers/Language/Utilities/StringUtilities.php b/src/View/Antlers/Language/Utilities/StringUtilities.php index 38f8a6afcab..f114e64344e 100644 --- a/src/View/Antlers/Language/Utilities/StringUtilities.php +++ b/src/View/Antlers/Language/Utilities/StringUtilities.php @@ -79,19 +79,10 @@ public static function containsSymbolicCharacters($text) */ public static function sanitizePhp($text) { - $text = str_ireplace(' Date: Thu, 19 Mar 2026 17:08:16 +0000 Subject: [PATCH 4/5] update tests --- tests/Antlers/Runtime/PhpEnabledTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Antlers/Runtime/PhpEnabledTest.php b/tests/Antlers/Runtime/PhpEnabledTest.php index 76b954100d4..2c5c9980b9d 100644 --- a/tests/Antlers/Runtime/PhpEnabledTest.php +++ b/tests/Antlers/Runtime/PhpEnabledTest.php @@ -612,9 +612,9 @@ public function test_disabled_php_node_inside_user_values() public function test_sanitize_php_is_case_insensitive() { $this->assertSame('<?php echo "test"; ?>', StringUtilities::sanitizePhp('')); - $this->assertSame('<?php echo "test"; ?>', StringUtilities::sanitizePhp('')); - $this->assertSame('<?php echo "test"; ?>', StringUtilities::sanitizePhp('')); - $this->assertSame('<?php echo "test"; ?>', StringUtilities::sanitizePhp('')); + $this->assertSame('<?PHP echo "test"; ?>', StringUtilities::sanitizePhp('')); + $this->assertSame('<?Php echo "test"; ?>', StringUtilities::sanitizePhp('')); + $this->assertSame('<?pHp echo "test"; ?>', StringUtilities::sanitizePhp('')); } public function test_sanitize_php_handles_short_echo_tag() From c7c302f7205dd5a96bf9ca54a1590ea332299a69 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Thu, 19 Mar 2026 19:50:58 -0400 Subject: [PATCH 5/5] Add short open tag test to PHP sanitization tests Co-Authored-By: Claude Opus 4.6 --- tests/Antlers/Runtime/PhpEnabledTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Antlers/Runtime/PhpEnabledTest.php b/tests/Antlers/Runtime/PhpEnabledTest.php index 2c5c9980b9d..5f31dda431c 100644 --- a/tests/Antlers/Runtime/PhpEnabledTest.php +++ b/tests/Antlers/Runtime/PhpEnabledTest.php @@ -617,9 +617,10 @@ public function test_sanitize_php_is_case_insensitive() $this->assertSame('<?pHp echo "test"; ?>', StringUtilities::sanitizePhp('')); } - public function test_sanitize_php_handles_short_echo_tag() + public function test_sanitize_php_handles_short_tags() { $this->assertSame('<?= $var ?>', StringUtilities::sanitizePhp('')); $this->assertSame('<?="test"?>', StringUtilities::sanitizePhp('')); + $this->assertSame("<? echo 'test' ?>", StringUtilities::sanitizePhp("")); } }