comparison src/luan/LuanState.java @ 1133:ba4daf107e07

fix security bug
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 17 Jan 2018 20:59:42 -0700
parents dd36eae6aa04
children 7ef40e1923b7
comparison
equal deleted inserted replaced
1132:b70102bab110 1133:ba4daf107e07
12 import luan.modules.BasicLuan; 12 import luan.modules.BasicLuan;
13 import luan.modules.JavaLuan; 13 import luan.modules.JavaLuan;
14 14
15 15
16 public final class LuanState implements LuanCloneable { 16 public final class LuanState implements LuanCloneable {
17 public LuanJava java; 17 public LuanJavaOk javaOk;
18 private Map registry; 18 private Map registry;
19 private final List<Reference<Closeable>> onClose = new ArrayList<Reference<Closeable>>(); 19 private final List<Reference<Closeable>> onClose = new ArrayList<Reference<Closeable>>();
20 public boolean isLocked = false; 20 public boolean isLocked = false;
21 21
22 public LuanState() { 22 public LuanState() {
23 java = new LuanJava(); 23 javaOk = new LuanJavaOk();
24 registry = new HashMap(); 24 registry = new HashMap();
25 } 25 }
26 26
27 private LuanState(LuanState luan) {} 27 private LuanState(LuanState luan) {}
28 28
31 } 31 }
32 32
33 @Override public void deepenClone(LuanCloneable dc,LuanCloner cloner) { 33 @Override public void deepenClone(LuanCloneable dc,LuanCloner cloner) {
34 LuanState clone = (LuanState)dc; 34 LuanState clone = (LuanState)dc;
35 clone.registry = cloner.clone(registry); 35 clone.registry = cloner.clone(registry);
36 clone.java = (LuanJava)cloner.clone(java); 36 clone.javaOk = (LuanJavaOk)cloner.clone(javaOk);
37 if( cloner.type == LuanCloner.Type.INCREMENTAL ) 37 if( cloner.type == LuanCloner.Type.INCREMENTAL )
38 isLocked = true; 38 isLocked = true;
39 } 39 }
40 40
41 public Map registry() { 41 public Map registry() {
82 public Object index(Object obj,Object key) throws LuanException { 82 public Object index(Object obj,Object key) throws LuanException {
83 if( obj instanceof LuanTable ) { 83 if( obj instanceof LuanTable ) {
84 LuanTable tbl = (LuanTable)obj; 84 LuanTable tbl = (LuanTable)obj;
85 return tbl.get(this,key); 85 return tbl.get(this,key);
86 } 86 }
87 if( obj != null && java.ok ) 87 if( obj != null && javaOk.ok )
88 return JavaLuan.__index(this,obj,key); 88 return JavaLuan.__index(this,obj,key);
89 throw new LuanException("attempt to index a " + Luan.type(obj) + " value" ); 89 throw new LuanException("attempt to index a " + Luan.type(obj) + " value" );
90 } 90 }
91 91
92 /* 92 /*