[前][次][番号順一覧][スレッド一覧]

ruby-changes:58396

From: Jeremy <ko1@a...>
Date: Thu, 24 Oct 2019 19:16:15 +0900 (JST)
Subject: [ruby-changes:58396] 2e37c1960a (master): [ruby/date] Remove taint support

https://git.ruby-lang.org/ruby.git/commit/?id=2e37c1960a

From 2e37c1960a0b84a9018dc0202a36daf4e692ed46 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Fri, 18 Oct 2019 11:56:05 -0700
Subject: [ruby/date] Remove taint support

Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous versions.

https://github.com/ruby/date/commit/519470dc3b

diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 0483d2d..9e4a4f2 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -4244,12 +4244,10 @@ date_s__strptime_internal(int argc, VALUE *argv, VALUE klass, https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L4244
 
 	if (!NIL_P(zone)) {
 	    rb_enc_copy(zone, vstr);
-	    OBJ_INFECT(zone, vstr);
 	    set_hash("zone", zone);
 	}
 	if (!NIL_P(left)) {
 	    rb_enc_copy(left, vstr);
-	    OBJ_INFECT(left, vstr);
 	    set_hash("leftover", left);
 	}
     }
@@ -4733,7 +4731,6 @@ d_lite_initialize(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L4731
     double sg;
 
     rb_check_frozen(self);
-    rb_check_trusted(self);
 
     rb_scan_args(argc, argv, "05", &vjd, &vdf, &vsf, &vof, &vsg);
 
@@ -4789,7 +4786,6 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L4786
 d_lite_initialize_copy(VALUE copy, VALUE date)
 {
     rb_check_frozen(copy);
-    rb_check_trusted(copy);
 
     if (copy == date)
 	return copy;
@@ -6762,7 +6758,6 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self, https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6758
 	    if (p > fmt) rb_str_cat(str, fmt, p - fmt);
 	}
 	rb_enc_copy(str, vfmt);
-	OBJ_INFECT(str, vfmt);
 	return str;
     }
     else
@@ -6771,7 +6766,6 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self, https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6766
     str = rb_str_new(buf, len);
     if (buf != buffer) xfree(buf);
     rb_enc_copy(str, vfmt);
-    OBJ_INFECT(str, vfmt);
     return str;
 }
 
@@ -7162,7 +7156,6 @@ d_lite_marshal_load(VALUE self, VALUE a) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7156
     get_d1(self);
 
     rb_check_frozen(self);
-    rb_check_trusted(self);
 
     if (!RB_TYPE_P(a, T_ARRAY))
 	rb_raise(rb_eTypeError, "expected an array");
diff --git a/test/date/test_date_parse.rb b/test/date/test_date_parse.rb
index dda952b..26c61eb 100644
--- a/test/date/test_date_parse.rb
+++ b/test/date/test_date_parse.rb
@@ -421,10 +421,9 @@ class TestDateParse < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/date/test_date_parse.rb#L421
       l = format('<failed at line %d>', l)
       assert_equal(y, a, l)
       if y[6]
-        h = Date._parse(x[0].dup.taint, *x[1..-1])
+        h = Date._parse(x[0].dup, *x[1..-1])
         assert_equal(y[6], h[:zone], l)
         assert_equal(y[6].encoding, h[:zone].encoding, l)
-        assert_predicate(h[:zone], :tainted?, l)
       end
     end
   end
diff --git a/test/date/test_switch_hitter.rb b/test/date/test_switch_hitter.rb
index 6c587d8..bdf299e 100644
--- a/test/date/test_switch_hitter.rb
+++ b/test/date/test_switch_hitter.rb
@@ -568,35 +568,6 @@ class TestSH < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/date/test_switch_hitter.rb#L568
     assert_equal(Date::GREGORIAN, d.start)
   end
 
-  def test_taint
-    h = Date._strptime('15:43+09:00', '%R%z')
-    assert_equal(false, h[:zone].tainted?)
-    h = Date._strptime('15:43+09:00'.dup.taint, '%R%z')
-    assert_equal(true, h[:zone].tainted?)
-
-    h = Date._strptime('1;1/0', '%d')
-    assert_equal(false, h[:leftover].tainted?)
-    h = Date._strptime('1;1/0'.dup.taint, '%d')
-    assert_equal(true, h[:leftover].tainted?)
-
-    h = Date._parse('15:43+09:00')
-    assert_equal(false, h[:zone].tainted?)
-    h = Date._parse('15:43+09:00'.dup.taint)
-    assert_equal(true, h[:zone].tainted?)
-
-    s = Date.today.strftime('new 105')
-    assert_equal(false, s.tainted?)
-    s = Date.today.strftime('new 105'.dup.taint)
-    assert_equal(true, s.tainted?)
-    s = Date.today.strftime("new \000 105".dup.taint)
-    assert_equal(true, s.tainted?)
-
-    s = DateTime.now.strftime('super $record')
-    assert_equal(false, s.tainted?)
-    s = DateTime.now.strftime('super $record'.dup.taint)
-    assert_equal(true, s.tainted?)
-  end
-
   def test_enc
     Date::MONTHNAMES.each do |s|
       assert_equal(Encoding::US_ASCII, s.encoding) if s
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]