From 528574c2e21e25fe1f848f77f4e7606636a7a2dc Mon Sep 17 00:00:00 2001 From: mame Date: Tue, 4 Aug 2009 16:44:05 +0000 Subject: * 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@24396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_object.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 51a3cdc32b..eff463f307 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 -- cgit v1.2.3