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
This commit is contained in:
normal 2017-07-18 09:52:55 +00:00
parent 1f67a3900f
commit 86e266bb60
2 changed files with 78 additions and 61 deletions

View file

@ -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