mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
array.c: no infection by unused separator
* array.c (rb_ary_join): should not infected by separator if it is not used. [ruby-core:42161][Bug #5902] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d12569b001
commit
d61dfcc793
3 changed files with 20 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat Jul 14 16:04:24 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_join): should not infected by separator if it is not
|
||||
used. [ruby-core:42161][Bug #5902]
|
||||
|
||||
Sat Jul 14 02:31:55 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* include/ruby/intern.h (rb_thread_blocking_region): fix declarations
|
||||
|
|
4
array.c
4
array.c
|
@ -1768,8 +1768,8 @@ rb_ary_join(VALUE ary, VALUE sep)
|
|||
VALUE val, tmp, result;
|
||||
|
||||
if (RARRAY_LEN(ary) == 0) return rb_usascii_str_new(0, 0);
|
||||
if (OBJ_TAINTED(ary) || OBJ_TAINTED(sep)) taint = TRUE;
|
||||
if (OBJ_UNTRUSTED(ary) || OBJ_UNTRUSTED(sep)) untrust = TRUE;
|
||||
if (OBJ_TAINTED(ary)) taint = TRUE;
|
||||
if (OBJ_UNTRUSTED(ary)) untrust = TRUE;
|
||||
|
||||
if (!NIL_P(sep)) {
|
||||
StringValue(sep);
|
||||
|
|
|
@ -920,6 +920,19 @@ class TestArray < Test::Unit::TestCase
|
|||
assert_equal(true, s.tainted?)
|
||||
assert_equal(true, s.untrusted?)
|
||||
|
||||
bug5902 = '[ruby-core:42161]'
|
||||
sep = ":".taint.untrust
|
||||
|
||||
s = @cls[].join(sep)
|
||||
assert_equal(false, s.tainted?, bug5902)
|
||||
assert_equal(false, s.untrusted?, bug5902)
|
||||
s = @cls[1].join(sep)
|
||||
assert_equal(false, s.tainted?, bug5902)
|
||||
assert_equal(false, s.untrusted?, bug5902)
|
||||
s = @cls[1, 2].join(sep)
|
||||
assert_equal(true, s.tainted?, bug5902)
|
||||
assert_equal(true, s.untrusted?, bug5902)
|
||||
|
||||
e = ''.force_encoding('EUC-JP')
|
||||
u = ''.force_encoding('UTF-8')
|
||||
assert_equal(Encoding::US_ASCII, [[]].join.encoding)
|
||||
|
|
Loading…
Reference in a new issue