mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Encode strings to utf-8 that are passed to compile
This commit is contained in:
parent
818e8351cc
commit
043c06b699
5 changed files with 10 additions and 2 deletions
|
@ -4,8 +4,10 @@ module ExecJS
|
|||
class ExternalRuntime
|
||||
class Context
|
||||
def initialize(runtime, source = "")
|
||||
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
||||
|
||||
@runtime = runtime
|
||||
@source = source.respond_to?(:encode) ? source.encode("UTF-8") : source
|
||||
@source = source
|
||||
end
|
||||
|
||||
def eval(source, options = {})
|
||||
|
|
|
@ -2,6 +2,8 @@ module ExecJS
|
|||
class MustangRuntime
|
||||
class Context
|
||||
def initialize(source = "")
|
||||
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
||||
|
||||
@v8_context = ::Mustang::Context.new
|
||||
@v8_context.eval(source)
|
||||
end
|
||||
|
|
|
@ -2,6 +2,8 @@ module ExecJS
|
|||
class RubyRacerRuntime
|
||||
class Context
|
||||
def initialize(source = "")
|
||||
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
||||
|
||||
@v8_context = ::V8::Context.new
|
||||
@v8_context.eval(source)
|
||||
end
|
||||
|
|
|
@ -2,6 +2,8 @@ module ExecJS
|
|||
class RubyRhinoRuntime
|
||||
class Context
|
||||
def initialize(source = "")
|
||||
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
||||
|
||||
@rhino_context = ::Rhino::Context.new
|
||||
@rhino_context.eval(source)
|
||||
end
|
||||
|
|
|
@ -69,7 +69,7 @@ class TestRuntime < Test::Unit::TestCase
|
|||
|
||||
assert_raise Encoding::UndefinedConversionError do
|
||||
binary = "\xde\xad\xbe\xef".force_encoding("BINARY")
|
||||
@runtime.eval(binary)
|
||||
context.eval(binary)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue