Skip to content
This repository has been archived by the owner on Aug 18, 2018. It is now read-only.

Commit

Permalink
Don't use the built-in eval.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarnette committed Apr 23, 2008
1 parent 12809c7 commit 5ffd6cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion js/johnson/prelude.js
Expand Up @@ -51,7 +51,7 @@ Johnson.require = function(file) {

if(Ruby.File.send("file?", path)) {
Johnson.required[file] = true;
eval(Ruby.File.read(path));
Johnson.currentContext.load(path);

return true;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/johnson/context.rb
Expand Up @@ -4,7 +4,8 @@ class Context

def initialize(delegate=Johnson::SpiderMonkey::Context)
@delegate = delegate.is_a?(Class) ? delegate.new : delegate
evaluate(Johnson::PRELUDE, 'Johnson::PRELUDE')
evaluate(Johnson::PRELUDE, "Johnson::PRELUDE", 1)
global.Johnson.currentContext = self
end

def [](key)
Expand All @@ -25,7 +26,7 @@ def global
end

def load(file)
delegate.evaluate(IO.read(file), file)
delegate.evaluate(IO.read(file), file, 1)
end
end
end

0 comments on commit 5ffd6cf

Please sign in to comment.