mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enum.c (rb_enum_join): non-nil separator must be convertible to
String. [ruby-core:24172] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9041ac4289
commit
e895bc3cdb
3 changed files with 15 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Jul 7 13:34:30 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* enum.c (rb_enum_join): non-nil separator must be convertible to
|
||||
String. [ruby-core:24172]
|
||||
|
||||
Tue Jul 7 12:47:28 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* enum.c (rb_enum_join): should propagate taint to the return
|
||||
|
|
1
enum.c
1
enum.c
|
@ -1828,6 +1828,7 @@ rb_enum_join(VALUE obj, VALUE sep)
|
|||
|
||||
args[0] = 0;
|
||||
args[1] = sep;
|
||||
if (!NIL_P(sep)) StringValue(args[1]);
|
||||
rb_block_call(obj, id_each, 0, 0, join_i, (VALUE)args);
|
||||
if (!args[0]) args[0] = rb_str_new(0, 0);
|
||||
OBJ_INFECT(args[0], obj);
|
||||
|
|
|
@ -285,8 +285,15 @@ class TestEnumerable < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_join
|
||||
ofs = $,
|
||||
assert_equal("abc", ("a".."c").join(""))
|
||||
assert_equal("a-b-c", ("a".."c").join("-"))
|
||||
$, = "-"
|
||||
assert_equal("a-b-c", ("a".."c").join())
|
||||
$, = nil
|
||||
assert_equal("abc", ("a".."c").join())
|
||||
assert_equal("123", (1..3).join())
|
||||
assert_raise(TypeError, '[ruby-core:24172]') {("a".."c").join(1)}
|
||||
class << (e = Object.new.extend(Enumerable))
|
||||
def to_s
|
||||
"e"
|
||||
|
@ -296,5 +303,7 @@ class TestEnumerable < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
assert_equal("e", e.join(""))
|
||||
ensure
|
||||
$, = ofs
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue