summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-09 14:33:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-09 14:33:11 +0000
commit62f7424640b0aff81834d3d310193ab9e1288bfb (patch)
tree1a3056244f47de1bf42299e5b308d8e551be628b /lib
parent2ce1fbeb59dd0a125d56f2500b0dba1a56380da0 (diff)
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')
-rw-r--r--lib/erb.rb11
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: