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, local_storage, dump) ⇒ Sandbox

:nodoc



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/s41c/sandbox.rb', line 10

def initialize(ole, local_storage, dump)
  @ole = ole
  @local_storage = local_storage

  dump.untaint
  hsh = Marshal.load(dump.unpack('m')[0])

  @vars = hsh[:vars]
  @vars.each do |key, value|
    self.instance_variable_set(:"@#{key}", value)
  end

  @code = proc {
    $SAFE = 3
    instance_eval hsh[:code], __FILE__, __LINE__
  }
end

Instance Method Details

#eval_codeObject

:nodoc



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/s41c/sandbox.rb', line 29

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