1
0
Fork 0
mirror of https://github.com/rails/execjs synced 2023-03-27 23:21:20 -04:00

Merge pull request #120 from casperisfine/fix-anonymous-eval

Avoid anonymous eval
This commit is contained in:
Jean Boussier 2023-01-11 15:01:58 +01:00 committed by GitHub
commit 1a61226215
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,7 +103,13 @@ module ExecJS
@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
@ -143,15 +149,6 @@ module ExecJS
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")