safe.rb:
$SAFE = 1
class C
def self.win_platform?
false
end
end
safe2.rb:
require 'safe'
class D < C
unless win_platform? then
def d
puts "ok!"
end
end
end
D.new.d
$ ruby18 -v safe2.rb
ruby 1.8.6 (2007-06-30 patchlevel 5000) [i686-darwin8.10.1]
ok!
$ ruby19 -v safe2.rb
ruby 1.9.0 (2007-08-23 patchlevel 0) [i686-darwin8.10.1]
syck.so: warning: method redefined; discarding old value
safe2.rb:4:in `<class:D>': calling insecure method: win_platform?
(SecurityError)
from safe2.rb:3:in `<main>'
--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars