@@ -12,6 +12,19 @@ function wrap($value, $sandbox){
1212 if (!($ value instanceof SandboxedString) && is_object ($ value ) && method_exists ($ value , '__toString ' )){
1313 $ strval = $ value ->__toString ();
1414 return is_callable ($ strval ) ? new SandboxedString ($ strval , $ sandbox ) : $ value ;
15+ } else if (is_array ($ value ) && count ($ value )){
16+ //save current array pointer
17+ $ current_key = key ($ value );
18+ foreach ($ value as $ key => &$ _value ) {
19+ $ value [$ key ] = wrap ($ _value , $ sandbox );
20+ }
21+ //rewind array pointer
22+ reset ($ value );
23+ //advance array to previous array key
24+ while (key ($ value ) !== $ current_key ){
25+ next ($ value );
26+ }
27+ return $ value ;
1528 } else if (is_string ($ value ) && is_callable ($ value )){
1629 return new SandboxedString ($ value , $ sandbox );
1730 }
@@ -29,6 +42,19 @@ function &wrapByRef(&$value, $sandbox){
2942 if (!($ value instanceof SandboxedString) && is_object ($ value ) && method_exists ($ value , '__toString ' )){
3043 $ strval = $ value ->__toString ();
3144 return is_callable ($ strval ) ? new SandboxedString ($ strval , $ sandbox ) : $ value ;
45+ } else if (is_array ($ value ) && count ($ value )){
46+ //save current array pointer
47+ $ current_key = key ($ value );
48+ foreach ($ value as $ key => &$ _value ) {
49+ $ value [$ key ] = wrap ($ _value , $ sandbox );
50+ }
51+ //rewind array pointer
52+ reset ($ value );
53+ //advance array to saved array pointer
54+ while (key ($ value ) !== $ current_key ){
55+ next ($ value );
56+ }
57+ return $ value ;
3258 } else if (is_string ($ value ) && is_callable ($ value )){
3359 return new SandboxedString ($ value , $ sandbox );
3460 }
0 commit comments