aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-06 12:05:12 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-06 12:05:12 +0000
commit2cdd0a87efe67c3a6a3ba48d6532ffa2e11bba5c (patch)
treea9e703eeebc8900ce947913b7734b8f9476ee5ee
parent5574d874fb0ead39ad34000cdae4b55327465af6 (diff)
downloadruby-2cdd0a87efe67c3a6a3ba48d6532ffa2e11bba5c.tar.gz
* ext/date/date_core.c: flattened format to strftimev.
* ext/date/date_core.c (date_strftime_internal): taints run. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/date/date_core.c20
-rw-r--r--test/date/test_switch_hitter.rb2
3 files changed, 18 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 06ef729f5d..35a432c97c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Jun 6 21:02:12 2011 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * 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@ruby-lang.org>
* include/ruby/{defines,missing}.h (rb_infinity, rb_nan): move from
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 5613088f89..8d3e54a79a 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -6476,6 +6476,8 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
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 @@ static VALUE
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 @@ strftimev(const char *fmt, VALUE self,
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 @@ d_lite_asctime(VALUE self)
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 @@ d_lite_iso8601(VALUE self)
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 @@ d_lite_jisx0301(VALUE self)
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 @@ static VALUE
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 @@ dt_lite_iso8601_timediv(VALUE self, VALUE n)
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 @@ dt_lite_iso8601(int argc, VALUE *argv, VALUE self)
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 @@ dt_lite_jisx0301(int argc, VALUE *argv, VALUE self)
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)),
diff --git a/test/date/test_switch_hitter.rb b/test/date/test_switch_hitter.rb
index 9500821b2b..6031708928 100644
--- a/test/date/test_switch_hitter.rb
+++ b/test/date/test_switch_hitter.rb
@@ -375,6 +375,8 @@ class TestSH < Test::Unit::TestCase
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?)