File tree Expand file tree Collapse file tree
src/View/Antlers/Language/Utilities Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,15 +79,10 @@ public static function containsSymbolicCharacters($text)
7979 */
8080 public static function sanitizePhp ($ text )
8181 {
82- $ text = str_replace ('<?php ' , '<?php ' , $ text );
83-
84- // Also replace short tags if they're enabled.
85- if (ini_get ('short_open_tag ' )) {
86- $ xmlPlaceholder = '__XML_PLACEHOLDER ' .Str::uuid ();
87- $ text = str_replace ('<?xml ' , $ xmlPlaceholder , $ text );
88- $ text = str_replace ('<? ' , '<? ' , $ text );
89- $ text = str_replace ($ xmlPlaceholder , '<?xml ' , $ text );
90- }
82+ $ xmlPlaceholder = '__XML_PLACEHOLDER ' .Str::uuid ();
83+ $ text = str_replace ('<?xml ' , $ xmlPlaceholder , $ text );
84+ $ text = str_replace ('<? ' , '<? ' , $ text );
85+ $ text = str_replace ($ xmlPlaceholder , '<?xml ' , $ text );
9186
9287 return $ text ;
9388 }
Original file line number Diff line number Diff line change @@ -608,4 +608,19 @@ public function test_disabled_php_node_inside_user_values()
608608
609609 GlobalRuntimeState::$ allowPhpInContent = false ;
610610 }
611+
612+ public function test_sanitize_php_is_case_insensitive ()
613+ {
614+ $ this ->assertSame ('<?php echo "test"; ?> ' , StringUtilities::sanitizePhp ('<?php echo "test"; ?> ' ));
615+ $ this ->assertSame ('<?PHP echo "test"; ?> ' , StringUtilities::sanitizePhp ('<?PHP echo "test"; ?> ' ));
616+ $ this ->assertSame ('<?Php echo "test"; ?> ' , StringUtilities::sanitizePhp ('<?Php echo "test"; ?> ' ));
617+ $ this ->assertSame ('<?pHp echo "test"; ?> ' , StringUtilities::sanitizePhp ('<?pHp echo "test"; ?> ' ));
618+ }
619+
620+ public function test_sanitize_php_handles_short_tags ()
621+ {
622+ $ this ->assertSame ('<?= $var ?> ' , StringUtilities::sanitizePhp ('<?= $var ?> ' ));
623+ $ this ->assertSame ('<?="test"?> ' , StringUtilities::sanitizePhp ('<?="test"?> ' ));
624+ $ this ->assertSame ("<? echo 'test' ?> " , StringUtilities::sanitizePhp ("<? echo 'test' ?> " ));
625+ }
611626}
You can’t perform that action at this time.
0 commit comments