Skip to content

Commit

Permalink
Merge pull request #120 from casperisfine/fix-anonymous-eval
Browse files Browse the repository at this point in the history
Avoid anonymous eval
  • Loading branch information
byroot authored Jan 11, 2023
2 parents e553b3f + 1c1770d commit 1a61226
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/execjs/external_runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ def initialize(options)
@popen_options[:internal_encoding] = ::Encoding.default_internal || 'UTF-8'

if @runner_path
instance_eval generate_compile_method(@runner_path)
instance_eval <<~RUBY, __FILE__, __LINE__
def compile_source(source)
<<-RUNNER
#{IO.read(@runner_path)}
RUNNER
end
RUBY
end
end

Expand Down Expand Up @@ -143,15 +149,6 @@ def locate_executable(command)
end

protected
def generate_compile_method(path)
<<-RUBY
def compile_source(source)
<<-RUNNER
#{IO.read(path)}
RUNNER
end
RUBY
end

def json2_source
@json2_source ||= IO.read(ExecJS.root + "/support/json2.js")
Expand Down

0 comments on commit 1a61226

Please sign in to comment.