summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-17 04:35:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-17 04:35:26 +0000
commiteec8adb168b7a778ed1c087c93e73e470fd4ec64 (patch)
tree38821172577903d9d534bba5af79aeeb55461880
parente64d814101fc0ee5c856ef55282c1efd6db3681c (diff)
transcode.c: infection
* transcode.c (rb_econv_substr_append, econv_primitive_convert): the result should be infected by the original string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_econv.rb1
-rw-r--r--transcode.c5
3 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index bbe9e7c982..396bed0806 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Dec 17 13:35:27 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * transcode.c (rb_econv_substr_append, econv_primitive_convert):
+ the result should be infected by the original string.
+
Thu Dec 17 09:46:08 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* re.c (reg_names_iter): should consider encoding of regexp.
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb
index 8172bf99ef..6f098db454 100644
--- a/test/ruby/test_econv.rb
+++ b/test/ruby/test_econv.rb
@@ -680,6 +680,7 @@ class TestEncodingConverter < Test::Unit::TestCase
ec = Encoding::Converter.new("utf-8", "euc-jp")
assert_raise(Encoding::InvalidByteSequenceError) { ec.convert("a\x80") }
assert_raise(Encoding::UndefinedConversionError) { ec.convert("\ufffd") }
+ assert_predicate(ec.convert("abc".taint), :tainted?)
ret = ec.primitive_convert(nil, "", nil, nil)
assert_equal(:finished, ret)
assert_raise(ArgumentError) { ec.convert("a") }
diff --git a/transcode.c b/transcode.c
index 1977498bc6..c2032a897a 100644
--- a/transcode.c
+++ b/transcode.c
@@ -1854,6 +1854,7 @@ rb_econv_substr_append(rb_econv_t *ec, VALUE src, long off, long len, VALUE dst,
src = rb_str_new_frozen(src);
dst = rb_econv_append(ec, RSTRING_PTR(src) + off, len, dst, flags);
RB_GC_GUARD(src);
+ OBJ_INFECT_RAW(dst, src);
return dst;
}
@@ -3768,8 +3769,10 @@ econv_primitive_convert(int argc, VALUE *argv, VALUE self)
res = rb_econv_convert(ec, &ip, is, &op, os, flags);
rb_str_set_len(output, op-(unsigned char *)RSTRING_PTR(output));
- if (!NIL_P(input))
+ if (!NIL_P(input)) {
+ OBJ_INFECT_RAW(output, input);
rb_str_drop_bytes(input, ip - (unsigned char *)RSTRING_PTR(input));
+ }
if (NIL_P(output_bytesize_v) && res == econv_destination_buffer_full) {
if (LONG_MAX / 2 < output_bytesize)