lib/openwfe/util/safe.rb in openwferu-0.9.11 vs lib/openwfe/util/safe.rb in openwferu-0.9.12

- old
+ new

@@ -84,36 +84,44 @@ # # Runs some code within an instance's realm at a certain safety level. # def OpenWFE.instance_eval_safely (instance, code, safe_level) + return instance.instance_eval(code) if on_jruby? + code.untaint r = nil Thread.new do $SAFE = safe_level r = instance.instance_eval(code) end.join + raise "cannot TAMPER with JRUBY_VERSION" if on_jruby? + r end # # Runs an eval() call at a certain safety level. # def OpenWFE.eval_safely (code, safe_level, binding=nil) + return eval(code, binding) if on_jruby? + code.untaint r = nil Thread.new do $SAFE = safe_level r = eval(code, binding) end.join + raise "cannot TAMPER with JRUBY_VERSION" if on_jruby? + r end # # - not used currently - @@ -135,9 +143,15 @@ c << "\n" end end eval_safely(c, safe_level, binding) + end + + protected + + def on_jruby? + defined?(JRUBY_VERSION) != nil end end