File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 7
7
*/
8
8
namespace TwigBridge \Node ;
9
9
10
+ use ArrayAccess ;
10
11
use Twig \Compiler ;
11
12
use Twig \Environment ;
12
13
use Twig \Error \RuntimeError ;
@@ -129,7 +130,12 @@ public static function attribute(
129
130
$ sandboxed = false ,
130
131
int $ lineno = -1
131
132
) {
132
- if (Template::METHOD_CALL !== $ type and is_a ($ object , 'Illuminate\Database\Eloquent\Model ' )) {
133
+ // Twig doesn't support sandboxing on objects that implement ArrayAccess
134
+ // https://github.com/twigphp/Twig/issues/106#issuecomment-583737
135
+ // https://github.com/twigphp/Twig/pull/1863
136
+ //
137
+ // https://github.com/twigphp/Twig/issues/2878
138
+ if (Template::METHOD_CALL !== $ type and $ object instanceof ArrayAccess) {
133
139
// We can't easily find out if an attribute actually exists, so return true
134
140
if ($ isDefinedTest ) {
135
141
return true ;
@@ -139,7 +145,7 @@ public static function attribute(
139
145
$ env ->getExtension (SandboxExtension::class)->checkPropertyAllowed ($ object , $ item );
140
146
}
141
147
142
- // Call the attribute, the Model object does the rest of the magic
148
+ // Call the attribute, the object does the rest of the magic
143
149
return $ object ->$ item ;
144
150
}
145
151
You can’t perform that action at this time.
0 commit comments