Skip to content

Fatal Error using filter _replace_ with Sandbox + StrictParsing #347

@NoNoNo

Description

@NoNoNo

Version: Latte 3.0.10 (latest), PHP 8.1.24

Bug Description

Using filter replace in Sandbox & StrictParsing mode:

Fatal error: Uncaught Latte\CompileException: Forbidden variable $this. in vendor/latte/latte/src/Latte/Essential/Passes.php on line 113

Steps To Reproduce

<?php

require_once 'vendor/autoload.php';

$latte = new \Latte\Engine;
$latte->setPolicy(\Latte\Sandbox\SecurityPolicy::createSafePolicy());
$latte->setSandboxMode();
$latte->setStrictParsing();
$latte->setLoader(new \Latte\Loaders\StringLoader);
$latte->render('{$test|replace("foo", "case")}', ['test' => 'test-foo']);

Expected Behavior

Output of string test-case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions