[前][次][番号順一覧][スレッド一覧]

ruby-changes:41093

From: nobu <ko1@a...>
Date: Thu, 17 Dec 2015 13:35:39 +0900 (JST)
Subject: [ruby-changes:41093] nobu:r53168 (trunk): transcode.c: infection

nobu	2015-12-17 13:35:26 +0900 (Thu, 17 Dec 2015)

  New Revision: 53168

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53168

  Log:
    transcode.c: infection
    
    * transcode.c (rb_econv_substr_append, econv_primitive_convert):
      the result should be infected by the original string.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_econv.rb
    trunk/transcode.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53167)
+++ ChangeLog	(revision 53168)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Dec 17 13:35:27 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* re.c (reg_names_iter): should consider encoding of regexp.
Index: test/ruby/test_econv.rb
===================================================================
--- test/ruby/test_econv.rb	(revision 53167)
+++ test/ruby/test_econv.rb	(revision 53168)
@@ -680,6 +680,7 @@ class TestEncodingConverter < Test::Unit https://github.com/ruby/ruby/blob/trunk/test/ruby/test_econv.rb#L680
     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") }
Index: transcode.c
===================================================================
--- transcode.c	(revision 53167)
+++ transcode.c	(revision 53168)
@@ -1854,6 +1854,7 @@ rb_econv_substr_append(rb_econv_t *ec, V https://github.com/ruby/ruby/blob/trunk/transcode.c#L1854
     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 https://github.com/ruby/ruby/blob/trunk/transcode.c#L3769
 
     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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]