Permalink
Browse files

Hash#{clone, dup} will copy status of untrust.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

a = { 1 => 'one', 2 => 'two', 3 => 'three' }
a.untrust
a.taint
a.freeze

b = a.clone
assert_equal(a.untrusted?, b.untrusted?)
assert_equal(a.tainted?, b.tainted?)
assert_equal(a.frozen?, b.frozen?)

c = a.dup
assert_equal(a.untrusted?, c.untrusted?)
assert_equal(a.tainted?, c.tainted?)
assert_equal(false, c.frozen?)

puts :ok
}}}

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5306 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
Watson1978 committed Mar 25, 2011
1 parent cf1bc99 commit 68162bf1a467a58c87a47e866cf2d0ca621fd1ba
Showing with 2 additions and 6 deletions.
  1. +2 −6 hash.c
View
8 hash.c
@@ -168,9 +168,7 @@ rhash_dup(VALUE rcv, SEL sel)
VALUE dup = rhash_copy(rcv, klass);
- if (OBJ_TAINTED(rcv)) {
- OBJ_TAINT(dup);
- }
+ OBJ_INFECT(dup, rcv);
return dup;
}
@@ -179,9 +177,7 @@ rhash_clone(VALUE rcv, SEL sel)
{
VALUE clone = rhash_copy(rcv, CLASS_OF(rcv));
- if (OBJ_TAINTED(rcv)) {
- OBJ_TAINT(clone);
- }
+ OBJ_INFECT(clone, rcv);
if (OBJ_FROZEN(rcv)) {
OBJ_FREEZE(clone);
}

0 comments on commit 68162bf

Please sign in to comment.