Bump version to 3.28.0 for the always_allowed_in_sandbox feature

This commit is contained in:
Fabien Potencier
2026-06-02 22:13:56 +02:00
parent 1c53b790fb
commit 29c4325afd
6 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -316,7 +316,7 @@ Sandbox
``Twig\TwigCallableInterface`` implementations (``TwigFilter``,
``TwigFunction``, ``TwigTest``) and in
``Twig\TokenParser\TokenParserInterface`` implementations is deprecated as
of Twig 3.27. This method will be added to both interfaces in Twig 4.0. It
of Twig 3.28. This method will be added to both interfaces in Twig 4.0. It
returns ``true`` when the filter, function, test, or tag is always allowed
in a sandboxed template, regardless of the security policy allow-list.
Custom callables extending ``Twig\AbstractTwigCallable`` and custom token
+2 -2
View File
@@ -60,11 +60,11 @@ allowed and will generate a ``\Twig\Sandbox\SecurityError`` exception.
Marking Filters, Functions, and Tags as Always Allowed
------------------------------------------------------
.. versionadded:: 3.27
.. versionadded:: 3.28
The ``always_allowed_in_sandbox`` option for filters and functions, and
the ``isAlwaysAllowedInSandbox()`` method for token parsers, were added in
Twig 3.27.
Twig 3.28.
Some filters, functions, and tags are inherently safe and should always be
usable in sandboxed templates without forcing every policy to allow-list them.
+1 -1
View File
@@ -263,7 +263,7 @@ final class SandboxNodeVisitor implements NodeVisitorInterface
}
$interface = $subject instanceof TokenParserInterface ? TokenParserInterface::class : TwigCallableInterface::class;
trigger_deprecation('twig/twig', '3.27', 'Not implementing the "isAlwaysAllowedInSandbox()" method in "%s" is deprecated. This method will be part of the "%s" interface in 4.0.', $subject::class, $interface);
trigger_deprecation('twig/twig', '3.28', 'Not implementing the "isAlwaysAllowedInSandbox()" method in "%s" is deprecated. This method will be part of the "%s" interface in 4.0.', $subject::class, $interface);
return false;
}
+1 -1
View File
@@ -21,7 +21,7 @@ use Twig\Token;
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @method bool isAlwaysAllowedInSandbox() Whether the tag is always allowed in sandbox mode, even when not explicitly allow-listed. Not implementing this method is deprecated since Twig 3.27, it will be required in 4.0.
* @method bool isAlwaysAllowedInSandbox() Whether the tag is always allowed in sandbox mode, even when not explicitly allow-listed. Not implementing this method is deprecated since Twig 3.28, it will be required in 4.0.
*/
interface TokenParserInterface
{
+1 -1
View File
@@ -15,7 +15,7 @@ namespace Twig;
* @author Fabien Potencier <fabien@symfony.com>
*
* @method bool needsIsSandboxed() Whether the callable needs the current sandbox state passed as an argument. Not implementing this method is deprecated since Twig 3.25, it will be required in 4.0.
* @method bool isAlwaysAllowedInSandbox() Whether the callable is always allowed in sandbox mode, even when not explicitly allow-listed. Not implementing this method is deprecated since Twig 3.27, it will be required in 4.0.
* @method bool isAlwaysAllowedInSandbox() Whether the callable is always allowed in sandbox mode, even when not explicitly allow-listed. Not implementing this method is deprecated since Twig 3.28, it will be required in 4.0.
*/
interface TwigCallableInterface extends \Stringable
{
+1 -1
View File
@@ -2140,7 +2140,7 @@ EOF
$twig = $this->getEnvironment(true, [], ['index' => '{% legacy_tag %}'], tags: ['legacy_tag']);
$twig->addTokenParser(new LegacyTokenParserWithoutIsAlwaysAllowedInSandbox());
$this->expectDeprecation(\sprintf('Since twig/twig 3.27: Not implementing the "isAlwaysAllowedInSandbox()" method in "%s" is deprecated. This method will be part of the "Twig\TokenParser\TokenParserInterface" interface in 4.0.', LegacyTokenParserWithoutIsAlwaysAllowedInSandbox::class));
$this->expectDeprecation(\sprintf('Since twig/twig 3.28: Not implementing the "isAlwaysAllowedInSandbox()" method in "%s" is deprecated. This method will be part of the "Twig\TokenParser\TokenParserInterface" interface in 4.0.', LegacyTokenParserWithoutIsAlwaysAllowedInSandbox::class));
// tag is allow-listed, so the render itself succeeds; the deprecation fires from the sandbox visitor while compiling
$this->assertSame('', $twig->load('index')->render([]));