Merge branch 'issue-594' into '6.x'

Resolve issue #594

See merge request nightlycommit/twing!587
This commit is contained in:
Eric MORAND 2023-12-01 20:41:36 +00:00
commit 83cc625cf0
5 changed files with 44 additions and 1 deletions

View File

@ -34,7 +34,7 @@ export const createCheckToStringNode = (
.then((value) => {
if (sandboxed) {
const assertToStringAllowed = getTraceableMethod((value: any) => {
if (typeof value === 'object') {
if ((value !== null) && (typeof value === 'object')) {
try {
template.checkMethodAllowed(value, 'toString');
} catch (error) {

View File

@ -3,5 +3,6 @@ import "./when-enabled";
import "./with-filter";
import "./with-function";
import "./with-method";
import "./with-missing-variable";
import "./with-property";
import "./with-tag";

View File

@ -0,0 +1,25 @@
import {runTest} from "../TestBase";
runTest({
description: '"sandbox" tag with missing variable',
templates: {
"index.twig": `{{ foo }}`
},
environmentOptions: {
sandboxed: true,
strictVariables: false
},
expectation: ''
});
runTest({
description: '"sandbox" tag with missing variable',
templates: {
"index.twig": `{{ foo.bar() }}`
},
environmentOptions: {
sandboxed: true,
strictVariables: false
},
expectation: ''
});

View File

@ -9,4 +9,5 @@ import "./not_valid2";
import "./range_operator";
import "./simple";
import "./with-embed-tag";
import "./with-missing-variable";
import "./within-a-sandboxed-environment";

View File

@ -0,0 +1,16 @@
import {runTest} from "../../TestBase";
runTest({
description: '"sandbox" tag with missing variable',
templates: {
"index.twig": `{% sandbox %}
{% include "foo.twig" %}
{% endsandbox %}
`,
'foo.twig': `{{ foo }}`
},
environmentOptions: {
strictVariables: false
},
expectation: ''
});