From 0c7b5f09499ea9c234831e327143a15d7fb07ea0 Mon Sep 17 00:00:00 2001 From: Alex Schickedanz Date: Thu, 1 Jan 2026 23:24:45 +0100 Subject: [PATCH] Fix {strip} block removing spaces between HTML attributes. {strip} removed spaces between HTML attributes in some cases like e.g., ``. This is due to the Smarty tag in the middle splitting the text block up and so the regex does not recognize the HTML attribute. --- src/Compiler/Template.php | 1 + .../TemplateSource/TagTests/Strip/CompileStripTest.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/Compiler/Template.php b/src/Compiler/Template.php index efc52162b..5c907d36e 100644 --- a/src/Compiler/Template.php +++ b/src/Compiler/Template.php @@ -571,6 +571,7 @@ public function processText($text) { '#(:SMARTY@!@|>)[\040\011]*[\n]\s*(?=@!@SMARTY:|<)#s' => '\1\2', // remove multiple spaces between attributes (but not in attribute values!) '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', + '#"[\t\s]*\n+[\t\s]*([a-z-]+=")#is' => '" \1', '#>[\040\011]+$#Ss' => '> ', '#>[\040\011]*[\n]\s*$#Ss' => '>', $this->stripRegEx => '', diff --git a/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php b/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php index 35b2eaacb..3924521f9 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php @@ -61,6 +61,8 @@ public function dataTestStrip() '', '', $i ++), array("\n foo\n bar\n", " foobar", '', $i ++), + array("link-text", 'link-text', '', $i ++), + array("text", 'text', '', $i ++), // variable in html tag array("\n c\n", 'c', '', $i ++), array("\n c\n", ' c', '', $i ++),