Class: S41C::Sandbox

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/s41c/sandbox.rb

Overview

:nodoc

Instance Method Summary collapse

Methods included from Utils

#get_1c_id, #to_bin, #to_utf8

Constructor Details

#initialize(ole, dump) ⇒ Sandbox

:nodoc



10
11
12
13
14
15
16
17
18
19
# File 'lib/s41c/sandbox.rb', line 10

def initialize(ole, dump)
  @ole = ole
  dump.untaint
  hsh = Marshal.load(dump)
  @vars = hsh[:vars]
  @code = proc {
    $SAFE = 3
    instance_eval hsh[:code], __FILE__, __LINE__
  }
end

Instance Method Details

#eval_codeObject

:nodoc



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/s41c/sandbox.rb', line 22

def eval_code
  begin
    @code.call
  rescue WIN32OLERuntimeError => e
    "Error: #{to_utf8(e.message)}"
  rescue Exception => e
    "Error: #{e.message}"
  rescue => e
    "Error: #{e.message} from #{__FILE__}:#{__LINE__}"
  end
end