Permalink
Browse files

Encode strings to utf-8 that are passed to compile

  • Loading branch information...
1 parent 818e835 commit 043c06b6997c4391b4cb1ac4c07ef7aa76b65fcd @josh josh committed Jun 8, 2011
@@ -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 @@ def test_encoding_compile
assert_raise Encoding::UndefinedConversionError do
binary = "\xde\xad\xbe\xef".force_encoding("BINARY")
- @runtime.eval(binary)
+ context.eval(binary)
end
end
end

0 comments on commit 043c06b

Please sign in to comment.