diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-09 14:33:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-09 14:33:11 +0000 |
commit | 62f7424640b0aff81834d3d310193ab9e1288bfb (patch) | |
tree | 1a3056244f47de1bf42299e5b308d8e551be628b /lib/erb.rb | |
parent | 2ce1fbeb59dd0a125d56f2500b0dba1a56380da0 (diff) | |
download | ruby-62f7424640b0aff81834d3d310193ab9e1288bfb.tar.gz |
erb.rb: safe concurrent use
* lib/erb.rb (ERB#run, ERB#result): eval under isolated bindings for
safe concurrent use. [ruby-core:47638] [Bug #7046]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/erb.rb')
-rw-r--r-- | lib/erb.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/erb.rb b/lib/erb.rb index 26c34ee3ad..934d83aa48 100644 --- a/lib/erb.rb +++ b/lib/erb.rb @@ -1,3 +1,4 @@ +# -*- coding: us-ascii -*- # = ERB -- Ruby Templating # # Author:: Masatoshi SEKI @@ -818,7 +819,7 @@ class ERB end # Generate results and print them. (see ERB#result) - def run(b=TOPLEVEL_BINDING) + def run(b=new_toplevel) print self.result(b) end @@ -830,7 +831,7 @@ class ERB # _b_ accepts a Binding or Proc object which is used to set the context of # code evaluation. # - def result(b=TOPLEVEL_BINDING) + def result(b=new_toplevel) if @safe_level proc { $SAFE = @safe_level @@ -841,6 +842,12 @@ class ERB end end + def new_toplevel + # New binding each time *near* toplevel for unspecified runs + TOPLEVEL_BINDING.dup + end + private :new_toplevel + # Define _methodname_ as instance method of _mod_ from compiled ruby source. # # example: |