From 86e266bb60e16c3a4868f6174aa8c4a5c50ff4a5 Mon Sep 17 00:00:00 2001 From: normal Date: Tue, 18 Jul 2017 09:52:55 +0000 Subject: string: preserve taint flag with String#-@ (uminus) * string.c (tainted_fstr_update): move up (rb_fstring): support registering tainted strings (register_fstring_tainted): extract from rb_fstring_existing0 (rb_tainted_fstring_existing): use register_fstring_tainted instead git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_string.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/ruby/test_string.rb') diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 1f21619798..84fa99c2bc 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -2749,10 +2749,15 @@ CODE assert_not_equal(str.object_id, (+str).object_id) assert_equal(str.object_id, (-str).object_id) + + return unless @cls == String bar = %w(b a r).join('') assert_not_predicate bar, :tainted? assert_not_predicate str, :tainted? assert_same(str, -bar, "uminus deduplicates [Feature #13077]") + bar = %w(b a r).taint.join('') + tstr = str.dup.taint + assert_same -tstr, -bar end def test_ord -- cgit v1.2.3