mirror of
https://github.com/twigphp/Twig.git
synced 2026-10-05 11:27:26 +00:00
Fix the sandbox not reporting the line of a rejected guard tag
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# 3.30.1 (2026-XX-XX)
|
||||
|
||||
* Speed up reading object attributes backed by getters or class constants
|
||||
* Fix the sandbox not reporting the line of a rejected `guard` tag
|
||||
|
||||
# 3.30.0 (2026-09-25)
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ final class GuardTokenParser extends AbstractTokenParser
|
||||
}
|
||||
$stream->expect(Token::BLOCK_END_TYPE);
|
||||
|
||||
return new Nodes([$exists ? $body : $else]);
|
||||
return new Nodes([$exists ? $body : $else], $token->getLine());
|
||||
}
|
||||
|
||||
public function decideGuardFork(Token $token): bool
|
||||
|
||||
@@ -142,6 +142,7 @@ class SandboxTest extends TestCase
|
||||
yield ['flush', '{% flush %}'];
|
||||
yield ['for', '{% for i in 1..2 %}{% endfor %}'];
|
||||
yield ['from', '{% from "macros" import foo %}'];
|
||||
yield ['guard', '{% guard function max %}{% endguard %}'];
|
||||
yield ['if', '{% if false %}{% endif %}'];
|
||||
yield ['import', '{% import "macros" as macros %}'];
|
||||
yield ['include', '{% include "macros" %}'];
|
||||
|
||||
Reference in New Issue
Block a user