summaryrefslogtreecommitdiff
path: root/test/ruby/test_time.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-17 07:26:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-17 07:26:45 +0000
commite2fd80b3d3b7f8ca7ffc2e7286fdb59e0c44bc79 (patch)
tree58bc2b44f4aed3cb90f5a1b45ea6ef25aff4ec52 /test/ruby/test_time.rb
parent18f0a65018dd357a1815941618d3cf9f274e6239 (diff)
* error.c (rb_check_trusted): new function to check an object is
trusted. * struct.c (rb_struct_modify), time.c (time_modify): check by the above function to show proper class names. [Bug #5036] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_time.rb')
-rw-r--r--test/ruby/test_time.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index aea4c2edc0..38e567a703 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -3,6 +3,7 @@ require 'rational'
require 'delegate'
require 'timeout'
require 'delegate'
+require_relative 'envutil'
class TestTime < Test::Unit::TestCase
def setup
@@ -702,7 +703,7 @@ class TestTime < Test::Unit::TestCase
bug5012 = "[ruby-dev:44071]"
t0 = Time.now
- class <<t0; end
+ class << t0; end
t1 = t0.getlocal
def t0.m
@@ -711,4 +712,18 @@ class TestTime < Test::Unit::TestCase
assert_raise(NoMethodError, bug5012) { t1.m }
end
+
+ def test_time_subclass
+ bug5036 = '[ruby-dev:44122]'
+ tc = Class.new(Time)
+ tc.inspect
+ t = tc.now
+ error = assert_raise(SecurityError) do
+ proc do
+ $SAFE = 4
+ t.gmtime
+ end.call
+ end
+ assert_equal("Insecure: can't modify #{tc}", error.message, bug5036)
+ end
end