summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-04 16:44:05 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-04 16:44:05 +0000
commit60ea0155bb3b71c82142da4e2ae89f824f859334 (patch)
tree8a1c4326493d9bbf2af4289dcce642700ed0edf9 /test
parent0619aadf5df0d662150cb9d9d0f2ad93044e350c (diff)
downloadruby-60ea0155bb3b71c82142da4e2ae89f824f859334.tar.gz
ruby-60ea0155bb3b71c82142da4e2ae89f824f859334.tar.xz
ruby-60ea0155bb3b71c82142da4e2ae89f824f859334.zip
* lib/pp.rb (guard_inspect_key): untrust internal hash to prevent
unexpected SecurityError. * test/ruby/test_object.rb: add a test for [ruby-dev:38982]. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_object.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 51a3cdc32..eff463f30 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -413,4 +413,40 @@ class TestObject < Test::Unit::TestCase
assert_equal(true, s.untrusted?)
assert_equal(true, s.tainted?)
end
+
+ def test_exec_recursive
+ Thread.current[:__recursive_key__] = nil
+ a = [[]]
+ a.inspect
+
+ assert_nothing_raised do
+ -> do
+ $SAFE = 4
+ begin
+ a.hash
+ rescue ArgumentError
+ end
+ end.call
+ end
+
+ -> do
+ assert_nothing_raised do
+ $SAFE = 4
+ a.inspect
+ end
+ end.call
+
+ -> do
+ o = Object.new
+ def o.to_ary(x); end
+ def o.==(x); $SAFE = 4; false; end
+ a = [[o]]
+ b = []
+ b << b
+
+ assert_nothing_raised do
+ b == a
+ end
+ end.call
+ end
end