ruby-changes:19892
From: tadf <ko1@a...>
Date: Mon, 6 Jun 2011 21:05:21 +0900 (JST)
Subject: [ruby-changes:19892] tadf:r31939 (trunk): * ext/date/date_core.c: flattened format to strftimev.
tadf 2011-06-06 21:05:12 +0900 (Mon, 06 Jun 2011) New Revision: 31939 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31939 Log: * ext/date/date_core.c: flattened format to strftimev. * ext/date/date_core.c (date_strftime_internal): taints run. Modified files: trunk/ChangeLog trunk/ext/date/date_core.c trunk/test/date/test_switch_hitter.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 31938) +++ ChangeLog (revision 31939) @@ -1,3 +1,8 @@ +Mon Jun 6 21:02:12 2011 Tadayoshi Funaba <tadf@d...> + + * ext/date/date_core.c: flattened format to strftimev. + * ext/date/date_core.c (date_strftime_internal): taints run. + Mon Jun 6 15:10:17 2011 NAKAMURA Usaku <usa@r...> * include/ruby/{defines,missing}.h (rb_infinity, rb_nan): move from Index: ext/date/date_core.c =================================================================== --- ext/date/date_core.c (revision 31938) +++ ext/date/date_core.c (revision 31939) @@ -6476,6 +6476,8 @@ for (fmt = p; p < pe && !*p; ++p); if (p > fmt) rb_str_cat(str, fmt, p - fmt); } + rb_enc_copy(str, vfmt); + OBJ_INFECT(str, vfmt); return str; } else @@ -6499,7 +6501,7 @@ d_lite_strftime(int argc, VALUE *argv, VALUE self) { return date_strftime_internal(argc, argv, self, - "%F", set_tmx); + "%Y-%m-%d", set_tmx); } static VALUE @@ -6529,7 +6531,7 @@ static VALUE d_lite_asctime(VALUE self) { - return strftimev("%c", self, set_tmx); + return strftimev("%a %b %e %H:%M:%S %Y", self, set_tmx); } /* @@ -6542,7 +6544,7 @@ static VALUE d_lite_iso8601(VALUE self) { - return strftimev("%F", self, set_tmx); + return strftimev("%Y-%m-%d", self, set_tmx); } /* @@ -6554,7 +6556,7 @@ static VALUE d_lite_rfc3339(VALUE self) { - return strftimev("%FT%T%:z", self, set_tmx); + return strftimev("%Y-%m-%dT%H:%M:%S%:z", self, set_tmx); } /* @@ -6624,7 +6626,7 @@ if (!gengo(m_real_local_jd(dat), m_real_year(dat), argv)) - return strftimev("%F", self, set_tmx); + return strftimev("%Y-%m-%d", self, set_tmx); return f_add(rb_f_sprintf(2, argv), strftimev(".%m.%d", self, set_tmx)); } @@ -7690,7 +7692,7 @@ dt_lite_strftime(int argc, VALUE *argv, VALUE self) { return date_strftime_internal(argc, argv, self, - "%FT%T%:z", set_tmx); + "%Y-%m-%dT%H:%M:%S%:z", set_tmx); } static VALUE @@ -7712,7 +7714,7 @@ f_expt(INT2FIX(10), n)))); f = rb_f_sprintf(3, argv); } - fmt = f_add3(rb_usascii_str_new2("T%T"), + fmt = f_add3(rb_usascii_str_new2("T%H:%M:%S"), f, rb_usascii_str_new2("%:z")); return strftimev(RSTRING_PTR(fmt), self, set_tmx); @@ -7736,7 +7738,7 @@ if (argc < 1) n = INT2FIX(0); - return f_add(strftimev("%F", self, set_tmx), + return f_add(strftimev("%Y-%m-%d", self, set_tmx), dt_lite_iso8601_timediv(self, n)); } @@ -7775,7 +7777,7 @@ if (!gengo(m_real_local_jd(dat), m_real_year(dat), argv2)) - return f_add(strftimev("%F", self, set_tmx), + return f_add(strftimev("%Y-%m-%d", self, set_tmx), dt_lite_iso8601_timediv(self, n)); return f_add(f_add(rb_f_sprintf(2, argv2), strftimev(".%m.%d", self, set_tmx)), Index: test/date/test_switch_hitter.rb =================================================================== --- test/date/test_switch_hitter.rb (revision 31938) +++ test/date/test_switch_hitter.rb (revision 31939) @@ -375,6 +375,8 @@ assert_equal(false, s.tainted?) s = Date.today.strftime('new 105'.taint) assert_equal(true, s.tainted?) + s = Date.today.strftime("new \000 105".taint) + assert_equal(true, s.tainted?) s = DateTime.now.strftime('super $record') assert_equal(false, s.tainted?) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/