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

ruby-changes:40789

From: nobu <ko1@a...>
Date: Thu, 3 Dec 2015 14:22:28 +0900 (JST)
Subject: [ruby-changes:40789] nobu:r52868 (trunk): range.c: infected by the receiver

nobu	2015-12-03 14:22:18 +0900 (Thu, 03 Dec 2015)

  New Revision: 52868

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

  Log:
    range.c: infected by the receiver
    
    * range.c (range_to_s): should be infected by the receiver.
      str2 infects by appending.  [ruby-core:71811] [Bug #11767]

  Modified files:
    trunk/ChangeLog
    trunk/range.c
    trunk/test/ruby/test_range.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52867)
+++ ChangeLog	(revision 52868)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Dec  3 14:22:16 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* range.c (range_to_s): should be infected by the receiver.
+	  str2 infects by appending.  [ruby-core:71811] [Bug #11767]
+
 Thu Dec  3 11:57:12 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in: separate SET_CURRENT_THREAD_NAME, which can set
Index: range.c
===================================================================
--- range.c	(revision 52867)
+++ range.c	(revision 52868)
@@ -1074,7 +1074,7 @@ range_to_s(VALUE range) https://github.com/ruby/ruby/blob/trunk/range.c#L1074
     str = rb_str_dup(str);
     rb_str_cat(str, "...", EXCL(range) ? 3 : 2);
     rb_str_append(str, str2);
-    OBJ_INFECT(str, str2);
+    OBJ_INFECT(str, range);
 
     return str;
 }
@@ -1092,7 +1092,7 @@ inspect_range(VALUE range, VALUE dummy, https://github.com/ruby/ruby/blob/trunk/range.c#L1092
     str = rb_str_dup(str);
     rb_str_cat(str, "...", EXCL(range) ? 3 : 2);
     rb_str_append(str, str2);
-    OBJ_INFECT(str, str2);
+    OBJ_INFECT(str, range);
 
     return str;
 }
Index: test/ruby/test_range.rb
===================================================================
--- test/ruby/test_range.rb	(revision 52867)
+++ test/ruby/test_range.rb	(revision 52868)
@@ -283,11 +283,21 @@ class TestRange < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_range.rb#L283
   def test_to_s
     assert_equal("0..1", (0..1).to_s)
     assert_equal("0...1", (0...1).to_s)
+
+    bug11767 = '[ruby-core:71811] [Bug #11767]'
+    assert_predicate(("0".taint.."1").to_s, :tainted?, bug11767)
+    assert_predicate(("0".."1".taint).to_s, :tainted?, bug11767)
+    assert_predicate(("0".."1").taint.to_s, :tainted?, bug11767)
   end
 
   def test_inspect
     assert_equal("0..1", (0..1).inspect)
     assert_equal("0...1", (0...1).inspect)
+
+    bug11767 = '[ruby-core:71811] [Bug #11767]'
+    assert_predicate(("0".taint.."1").inspect, :tainted?, bug11767)
+    assert_predicate(("0".."1".taint).inspect, :tainted?, bug11767)
+    assert_predicate(("0".."1").taint.inspect, :tainted?, bug11767)
   end
 
   def test_eqq

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

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