You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Template.php
+27-3Lines changed: 27 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@
15
15
useTwig\Error\Error;
16
16
useTwig\Error\LoaderError;
17
17
useTwig\Error\RuntimeError;
18
+
useTwig\Sandbox\SecurityError;
18
19
19
20
/**
20
21
* Default base class for compiled templates.
@@ -516,6 +517,7 @@ final protected function getContext($context, $item, $ignoreStrictCheck = false)
516
517
* @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true
517
518
*
518
519
* @throws RuntimeError if the attribute does not exist and Twig is running in strict mode and $isDefinedTest is false
520
+
* @throws SecurityError if the attribute is not allowed
519
521
*
520
522
* @internal
521
523
*/
@@ -591,17 +593,23 @@ protected function getAttribute($object, $item, array $arguments = [], $type = s
591
593
}
592
594
593
595
// object property
596
+
$propertySandboxException = null;
594
597
if (self::METHOD_CALL !== $type && !$objectinstanceof self) { // \Twig\Template does not have public properties, and we don't want to allow access to internal ones
595
598
if (isset($object->$item) || \array_key_exists((string) $item, $object)) {
596
599
if ($isDefinedTest) {
597
600
returntrue;
598
601
}
599
602
600
603
if ($this->env->hasExtension('\Twig\Extension\SandboxExtension')) {
0 commit comments