File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -226,6 +226,13 @@ public function validateTokens(MacroTokens $tokens): void
226226 } elseif ($ tokens ->isCurrent ('` ' )) {
227227 throw new CompileException ('Backtick operator is forbidden in Latte. ' );
228228
229+ } elseif (
230+ $ tokens ->isCurrent ($ tokens ::T_STRING )
231+ && $ tokenValue [0 ] === '" '
232+ && (strpos ($ tokenValue , '{$ ' ) !== false || strpos ($ tokenValue , '${ ' ) !== false )
233+ ) {
234+ throw new CompileException ('Forbidden complex expressions in strings. ' );
235+
229236 } elseif (
230237 Helpers::startsWith ($ tokenValue , '$ʟ_ ' )
231238 || ($ this ->policy && $ tokens ->isCurrent ('$this ' ))
Original file line number Diff line number Diff line change @@ -128,3 +128,15 @@ Assert::exception(function () use ($latte) {
128128Assert::exception (function () use ($ latte ) {
129129 $ latte ->compile ('{do new stdClass} ' );
130130}, Latte \CompileException::class, "Forbidden keyword 'new' inside tag. " );
131+
132+ Assert::exception (function () use ($ latte ) {
133+ $ latte ->compile ('{="{$var}"} ' );
134+ }, Latte \CompileException::class, 'Forbidden complex expressions in strings. ' );
135+
136+ Assert::exception (function () use ($ latte ) {
137+ $ latte ->compile ('{="${var}"} ' );
138+ }, Latte \CompileException::class, 'Forbidden complex expressions in strings. ' );
139+
140+ Assert::noError (function () use ($ latte ) {
141+ $ latte ->compile ('{= \'${var} \'} ' );
142+ });
You can’t perform that action at this time.
0 commit comments