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
+28-3Lines changed: 28 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,8 @@
15
15
useTwig\Error\Error;
16
16
useTwig\Error\LoaderError;
17
17
useTwig\Error\RuntimeError;
18
+
useTwig\Extension\SandboxExtension;
19
+
useTwig\Sandbox\SecurityError;
18
20
19
21
/**
20
22
* Default base class for compiled templates.
@@ -526,6 +528,7 @@ final protected function getContext($context, $item, $ignoreStrictCheck = false)
526
528
* @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true
527
529
*
528
530
* @throws RuntimeError if the attribute does not exist and Twig is running in strict mode and $isDefinedTest is false
531
+
* @throws SecurityError if the attribute is not allowed
529
532
*
530
533
* @internal
531
534
*/
@@ -601,17 +604,23 @@ protected function getAttribute($object, $item, array $arguments = [], $type = s
601
604
}
602
605
603
606
// object property
607
+
$propertySandboxException = null;
604
608
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
605
609
if (isset($object->$item) || \array_key_exists((string) $item, (array) $object)) {
606
610
if ($isDefinedTest) {
607
611
returntrue;
608
612
}
609
613
610
614
if ($this->env->hasExtension('\Twig\Extension\SandboxExtension')) {
0 commit comments