diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index f98d5b37774ada1552a2567f302e6a5f2d776f58..5226ff0cbe2556c9d3c38fa72fe1d6ce40aae862 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -151,9 +151,7 @@ def +(other) end def %(args) - args = Array(args) - - args.map! do |arg| + args = Array(args).map do |arg| if !html_safe? || arg.html_safe? arg else diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index eee2caa60eee16f1acb9ac09da3db1dad124f8bf..d3f52c04c4c80730e1d68754111bd5025a76aafd 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -463,6 +463,13 @@ def to_s assert @other_string.html_safe? end + test "Concatting with % doesn't modify a string" do + @other_string = ["

", "", "

"] + "%s %s %s".html_safe % @other_string + + assert_equal ["

", "", "

"], @other_string + end + test "Concatting a fixnum to safe always yields safe" do string = @string.html_safe string = string.concat(13)