Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions execjs.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ Gem::Specification.new do |s|
s.email = ["sstephenson@gmail.com", "josh@joshpeek.com"]

s.required_ruby_version = '>= 2.5.0'
s.add_dependency 'json', '>= 2'
end
6 changes: 3 additions & 3 deletions lib/execjs/external_runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def eval(source, options = {})
source = source.encode(Encoding::UTF_8)

if /\S/ =~ source
exec("return eval(#{::JSON.generate("(#{source})", quirks_mode: true)})")
exec("return eval(#{::JSON.generate("(#{source})")})")
end
end

Expand Down Expand Up @@ -66,7 +66,7 @@ def write_to_tempfile(contents)
end

def extract_result(output, filename)
status, value, stack = output.empty? ? [] : ::JSON.parse(output, create_additions: false)
status, value, stack = output.empty? ? [] : ::JSON.parse(output)
if status == "ok"
value
else
Expand Down Expand Up @@ -156,7 +156,7 @@ def json2_source

def encode_source(source)
encoded_source = encode_unicode_codepoints(source)
::JSON.generate("(function(){ #{encoded_source} })()", quirks_mode: true)
::JSON.generate("(function(){ #{encoded_source} })()")
end

def encode_unicode_codepoints(str)
Expand Down
2 changes: 1 addition & 1 deletion lib/execjs/ruby_rhino_runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def eval(source, options = {})
def call(properties, *args)
# Might no longer be necessary if therubyrhino handles Symbols directly:
# https://github.com/rubyjs/therubyrhino/issues/43
converted_args = JSON.parse(JSON.generate(args), create_additions: false)
converted_args = JSON.parse(JSON.generate(args))

unbox @rhino_context.eval(properties).call(*converted_args)
rescue Exception => e
Expand Down
4 changes: 2 additions & 2 deletions test/test_execjs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ def test_context_call_missing_function
{ "a" => 1, "b" => [2, 3]},
{ "a" => true }
].each_with_index do |value, index|
json_value = JSON.generate(value, quirks_mode: true)
json_value = JSON.generate(value)

define_method("test_json_value_#{index}") do
assert_output value, JSON.parse(json_value, quirks_mode: true)
assert_output value, JSON.parse(json_value)
end

define_method("test_exec_value_#{index}") do
Expand Down
Loading