diff --git a/doc/api.rst b/doc/api.rst index 59b1d3cbd..0a7e0cf45 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -484,12 +484,6 @@ able to call the ``getTitle()`` and ``getBody()`` methods on ``Article`` objects, and the ``title`` and ``body`` public properties. Everything else won't be allowed and will generate a ``\Twig\Sandbox\SecurityError`` exception. -.. caution:: - - The ``extends`` and ``use`` tags are always allowed in a sandboxed - template. That behavior will change in 4.0 where these tags will need to be - explicitly allowed like any other tag. - The policy object is the first argument of the sandbox constructor:: $sandbox = new \Twig\Extension\SandboxExtension($policy); diff --git a/src/ExpressionParser.php b/src/ExpressionParser.php index dbbb89b80..fbedcc547 100644 --- a/src/ExpressionParser.php +++ b/src/ExpressionParser.php @@ -538,10 +538,6 @@ class ExpressionParser public function parseFilterExpressionRaw($node) { - if (func_num_args() > 1) { - trigger_deprecation('twig/twig', '3.12', 'Passing a second argument to "%s()" is deprecated.', __METHOD__); - } - while (true) { $token = $this->parser->getStream()->expect(Token::NAME_TYPE); diff --git a/src/Node/Node.php b/src/Node/Node.php index 9e00f5cf0..d00c9e37d 100644 --- a/src/Node/Node.php +++ b/src/Node/Node.php @@ -54,10 +54,6 @@ class Node implements \Countable, \IteratorAggregate $this->nodes = $nodes; $this->attributes = $attributes; $this->lineno = $lineno; - - if (func_num_args() > 3) { - trigger_deprecation('twig/twig', '3.12', sprintf('The "tag" constructor argument of the "%s" class is deprecated and ignored (check which TokenParser class set it to "%s"), the tag is now automatically set by the Parser when needed.', static::class, func_get_arg(3) ?: 'null')); - } } public function __toString(): string diff --git a/src/Sandbox/SecurityPolicy.php b/src/Sandbox/SecurityPolicy.php index 2735ccb57..337a3ad6e 100644 --- a/src/Sandbox/SecurityPolicy.php +++ b/src/Sandbox/SecurityPolicy.php @@ -83,13 +83,7 @@ final class SecurityPolicy implements SecurityPolicyInterface { foreach ($tags as $tag) { if (!\in_array($tag, $this->allowedTags)) { - if ('extends' === $tag) { - trigger_deprecation('twig/twig', '3.12', 'The "extends" tag is always allowed in sandboxes, but won\'t be in 4.0, please enable it explicitely in your sandbox policy if needed.'); - } elseif ('use' === $tag) { - trigger_deprecation('twig/twig', '3.12', 'The "use" tag is always allowed in sandboxes, but won\'t be in 4.0, please enable it explicitely in your sandbox policy if needed.'); - } else { - throw new SecurityNotAllowedTagError(\sprintf('Tag "%s" is not allowed.', $tag), $tag); - } + throw new SecurityNotAllowedTagError(\sprintf('Tag "%s" is not allowed.', $tag), $tag); } } diff --git a/tests/Extension/SandboxTest.php b/tests/Extension/SandboxTest.php index 3011b40a0..d0eb498e1 100644 --- a/tests/Extension/SandboxTest.php +++ b/tests/Extension/SandboxTest.php @@ -88,8 +88,7 @@ class SandboxTest extends TestCase yield ['deprecated', '{% deprecated "message" %}']; yield ['do', '{% do 1 + 2 %}']; yield ['embed', '{% embed "base.twig" %}{% endembed %}']; - // To be uncommented in 4.0 - //yield ['extends', '{% extends "base.twig" %}']; + yield ['extends', '{% extends "base.twig" %}']; yield ['flush', '{% flush %}']; yield ['for', '{% for i in 1..2 %}{% endfor %}']; yield ['from', '{% from "macros" import foo %}']; @@ -99,28 +98,8 @@ class SandboxTest extends TestCase yield ['macro', '{% macro foo() %}{% endmacro %}']; yield ['sandbox', '{% sandbox %}{% endsandbox %}']; yield ['set', '{% set foo = 1 %}']; - // To be uncommented in 4.0 - //yield ['use', '{% use "1_empty" %}']; - yield ['with', '{% with foo %}{% endwith %}']; - } - - /** - * @dataProvider getSandboxedForExtendsAndUseTagsTests - * - * @group legacy - */ - public function testSandboxForExtendsAndUseTags(string $tag, string $template) - { - $this->expectDeprecation(sprintf('Since twig/twig 3.12: The "%s" tag is always allowed in sandboxes, but won\'t be in 4.0, please enable it explicitely in your sandbox policy if needed.', $tag)); - - $twig = $this->getEnvironment(true, [], self::$templates, []); - $twig->createTemplate($template, 'index')->render([]); - } - - public function getSandboxedForExtendsAndUseTagsTests() - { - yield ['extends', '{% extends "1_empty" %}']; yield ['use', '{% use "1_empty" %}']; + yield ['with', '{% with foo %}{% endwith %}']; } public function testSandboxWithInheritance()