Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove outdated Encoding workaround #113

Merged
merged 1 commit into from Mar 2, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/execjs/duktape_runtime.rb
Expand Up @@ -6,21 +6,21 @@ class DuktapeRuntime < Runtime
class Context < Runtime::Context
def initialize(runtime, source = "", options = {})
@ctx = Duktape::Context.new(complex_object: nil)
@ctx.exec_string(encode(source), '(execjs)')
@ctx.exec_string(source.encode(Encoding::UTF_8), '(execjs)')
rescue Exception => e
raise wrap_error(e)
end

def exec(source, options = {})
return unless /\S/ =~ source
@ctx.eval_string("(function(){#{encode(source)}})()", '(execjs)')
@ctx.eval_string("(function(){#{source.encode(Encoding::UTF_8)}})()", '(execjs)')
rescue Exception => e
raise wrap_error(e)
end

def eval(source, options = {})
return unless /\S/ =~ source
@ctx.eval_string("(#{encode(source)})", '(execjs)')
@ctx.eval_string("(#{source.encode(Encoding::UTF_8)})", '(execjs)')
rescue Exception => e
raise wrap_error(e)
end
Expand Down
26 changes: 0 additions & 26 deletions lib/execjs/encoding.rb

This file was deleted.

6 changes: 3 additions & 3 deletions lib/execjs/external_runtime.rb
Expand Up @@ -6,7 +6,7 @@ module ExecJS
class ExternalRuntime < Runtime
class Context < Runtime::Context
def initialize(runtime, source = "", options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)

@runtime = runtime
@source = source
Expand All @@ -16,15 +16,15 @@ def initialize(runtime, source = "", options = {})
end

def eval(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)

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

def exec(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)
source = "#{@source}\n#{source}" if @source != ""
source = @runtime.compile_source(source)

Expand Down
8 changes: 4 additions & 4 deletions lib/execjs/graaljs_runtime.rb
Expand Up @@ -8,7 +8,7 @@ def initialize(runtime, source = "", options = {})
@context.eval('js', 'delete this.console')
@js_object = @context.eval('js', 'Object')

source = encode(source)
source = source.encode(Encoding::UTF_8)
unless source.empty?
translate do
eval_in_context(source)
Expand All @@ -17,7 +17,7 @@ def initialize(runtime, source = "", options = {})
end

def exec(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)
source = "(function(){#{source}})()" if /\S/.match?(source)

translate do
Expand All @@ -26,7 +26,7 @@ def exec(source, options = {})
end

def eval(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)
source = "(#{source})" if /\S/.match?(source)

translate do
Expand All @@ -35,7 +35,7 @@ def eval(source, options = {})
end

def call(source, *args)
source = encode(source)
source = source.encode(Encoding::UTF_8)
source = "(#{source})" if /\S/.match?(source)

translate do
Expand Down
6 changes: 3 additions & 3 deletions lib/execjs/mini_racer_runtime.rb
Expand Up @@ -4,7 +4,7 @@ module ExecJS
class MiniRacerRuntime < Runtime
class Context < Runtime::Context
def initialize(runtime, source = "", options={})
source = encode(source)
source = source.encode(Encoding::UTF_8)
@context = ::MiniRacer::Context.new
@context.eval("delete this.console");
translate do
Expand All @@ -13,15 +13,15 @@ def initialize(runtime, source = "", options={})
end

def exec(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)

if /\S/ =~ source
eval "(function(){#{source}})()"
end
end

def eval(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)

if /\S/ =~ source
translate do
Expand Down
6 changes: 3 additions & 3 deletions lib/execjs/ruby_rhino_runtime.rb
Expand Up @@ -5,7 +5,7 @@ module ExecJS
class RubyRhinoRuntime < Runtime
class Context < Runtime::Context
def initialize(runtime, source = "", options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)

@rhino_context = ::Rhino::Context.new
fix_memory_limit! @rhino_context
Expand All @@ -15,15 +15,15 @@ def initialize(runtime, source = "", options = {})
end

def exec(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)

if /\S/ =~ source
eval "(function(){#{source}})()", options
end
end

def eval(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)

if /\S/ =~ source
unbox @rhino_context.eval("(#{source})")
Expand Down
4 changes: 0 additions & 4 deletions lib/execjs/runtime.rb
@@ -1,11 +1,7 @@
require "execjs/encoding"

module ExecJS
# Abstract base class for runtimes
class Runtime
class Context
include Encoding

def initialize(runtime, source = "", options = {})
end

Expand Down