From 26c59c251cac78c5420065042994297ba6a342ff Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 5 Feb 2026 23:05:19 +0900 Subject: [PATCH] Fix incorrect conversion of JS template variable containing path #2657 --- common/framework/Template.php | 2 +- tests/unit/framework/parsers/TemplateParserV2Test.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common/framework/Template.php b/common/framework/Template.php index 387c3ba6a..bd7d9165d 100644 --- a/common/framework/Template.php +++ b/common/framework/Template.php @@ -528,7 +528,7 @@ class Template */ public function isRelativePath(string $path): bool { - return !preg_match('#^((?:https?|file|data):|[\/\{<])#i', $path); + return !preg_match('#^((?:https?|file|data):|[\/\{\\\\<$\#@]|&\#x1B;)#i', $path); } /** diff --git a/tests/unit/framework/parsers/TemplateParserV2Test.php b/tests/unit/framework/parsers/TemplateParserV2Test.php index 9754800cf..0257ae05f 100644 --- a/tests/unit/framework/parsers/TemplateParserV2Test.php +++ b/tests/unit/framework/parsers/TemplateParserV2Test.php @@ -676,6 +676,16 @@ class TemplateParserV2Test extends \Codeception\Test\Unit $source = '

url(img/foo.jpg); }

'; $target = '

url(img/foo.jpg); }

'; $this->assertEquals($target, $this->_parse($source)); + + // No conversion if it's a template variable + $source = ''; + $target = ''; + $this->assertEquals($target, $this->_parse($source)); + + // No conversion if it's a JS template variable + $source = '@verbatim let src = `` @endverbatim'; + $target = ' let src = `` '; + $this->assertEquals($target, $this->_parse($source)); } public function testBlockConditions()