diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-08 14:58:32 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-08 14:58:32 +0000 |
commit | c4e2581392ef828160b760488d52c36464b451e3 (patch) | |
tree | 6be994a8440e7de03ba76144b1007f3581389412 /test | |
parent | 92d58cacaf93080c997f01075378a60e2bbb3f41 (diff) |
merge revision(s) r45676,r45677: [Backport #9769]
stringio.c: move GC guard
* ext/stringio/stringio.c (strio_write): move GC guard after the
last using position.
* ext/stringio/stringio.c (strio_write): use rb_str_append to
reuse coderange bits other than ASCII-8BIT, and keep
taintedness. [ruby-dev:48118] [Bug #9769]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/stringio/test_stringio.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index c7db91aae1..3fbe2f7eca 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -119,6 +119,24 @@ class TestStringIO < Test::Unit::TestCase f.close unless f.closed? end + def test_write_infection + bug9769 = '[ruby-dev:48118] [Bug #9769]' + s = "".untaint + f = StringIO.new(s, "w") + f.print("bar".taint) + f.close + assert_predicate(s, :tainted?, bug9769) + ensure + f.close unless f.closed? + end + + def test_write_encoding + s = "".force_encoding(Encoding::UTF_8) + f = StringIO.new(s) + f.print("\u{3053 3093 306b 3061 306f ff01}".b) + assert_equal(Encoding::UTF_8, s.encoding, "honor the original encoding over ASCII-8BIT") + end + def test_mode_error f = StringIO.new("", "r") assert_raise(IOError) { f.write("foo") } |