File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 42
42
( -dynamic ) . should_not equal ( "this string is frozen" . freeze )
43
43
( -dynamic ) . should_not equal ( -"this string is frozen" . freeze )
44
44
end
45
+
46
+ it "does not deduplicate tainted strings" do
47
+ dynamic = %w( this string is frozen ) . join ( ' ' )
48
+ dynamic . taint
49
+ ( -dynamic ) . should_not equal ( "this string is frozen" . freeze )
50
+ ( -dynamic ) . should_not equal ( -"this string is frozen" . freeze )
51
+ end
52
+
53
+ it "does not deduplicate strings with additional instance variables" do
54
+ dynamic = %w( this string is frozen ) . join ( ' ' )
55
+ dynamic . instance_variable_set ( :@foo , :bar )
56
+ ( -dynamic ) . should_not equal ( "this string is frozen" . freeze )
57
+ ( -dynamic ) . should_not equal ( -"this string is frozen" . freeze )
58
+ end
45
59
end
46
60
47
61
ruby_version_is "2.6" do
Original file line number Diff line number Diff line change @@ -1591,8 +1591,10 @@ def +@
1591
1591
1592
1592
def -@
1593
1593
str = frozen? ? self : dup . freeze
1594
- Truffle ::Ropes . flatten_rope ( str )
1595
- Truffle . invoke_primitive ( :string_intern , str )
1594
+ unless str . tainted? || !( str . instance_variables ) . empty?
1595
+ Truffle ::Ropes . flatten_rope ( str )
1596
+ Truffle . invoke_primitive ( :string_intern , str )
1597
+ end
1596
1598
end
1597
1599
1598
1600
def encoding
You can’t perform that action at this time.
0 commit comments