ruby-changes:64836
From: Nobuyoshi <ko1@a...>
Date: Tue, 12 Jan 2021 17:29:31 +0900 (JST)
Subject: [ruby-changes:64836] 1eb8eb55c2 (master): Convert time component strings to integers more strictly
https://git.ruby-lang.org/ruby.git/commit/?id=1eb8eb55c2 From 1eb8eb55c27b19e36d5bd23ce27f7ec2b9a7f521 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 12 Jan 2021 17:24:43 +0900 Subject: Convert time component strings to integers more strictly https://bugs.ruby-lang.org/issues/17485#change-89871 diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index e49753e..e5da0d6 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -46,6 +46,7 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time.rb#L46 t = Time.new(*tm, "-12:00") assert_equal([2001,2,28,23,59,30,-43200], [t.year, t.month, t.mday, t.hour, t.min, t.sec, t.gmt_offset], bug4090) assert_raise(ArgumentError) { Time.new(2000,1,1, 0,0,0, "+01:60") } + assert_raise(ArgumentError) { Time.new(2021, 1, 1, "+09:99") } end def test_time_add() diff --git a/time.c b/time.c index a395274..e7a211b 100644 --- a/time.c +++ b/time.c @@ -2793,7 +2793,7 @@ static int https://github.com/ruby/ruby/blob/trunk/time.c#L2793 obj2int(VALUE obj) { if (RB_TYPE_P(obj, T_STRING)) { - obj = rb_str_to_inum(obj, 10, FALSE); + obj = rb_str_to_inum(obj, 10, TRUE); } return NUM2INT(obj); @@ -2815,7 +2815,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/time.c#L2815 obj2vint(VALUE obj) { if (RB_TYPE_P(obj, T_STRING)) { - obj = rb_str_to_inum(obj, 10, FALSE); + obj = rb_str_to_inum(obj, 10, TRUE); } else { obj = rb_to_int(obj); @@ -2830,7 +2830,7 @@ obj2subsecx(VALUE obj, VALUE *subsecx) https://github.com/ruby/ruby/blob/trunk/time.c#L2830 VALUE subsec; if (RB_TYPE_P(obj, T_STRING)) { - obj = rb_str_to_inum(obj, 10, FALSE); + obj = rb_str_to_inum(obj, 10, TRUE); *subsecx = INT2FIX(0); } else { @@ -2844,7 +2844,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/time.c#L2844 usec2subsecx(VALUE obj) { if (RB_TYPE_P(obj, T_STRING)) { - obj = rb_str_to_inum(obj, 10, FALSE); + obj = rb_str_to_inum(obj, 10, TRUE); } return mulquov(num_exact(obj), INT2FIX(TIME_SCALE), INT2FIX(1000000)); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/