Skip to content
This repository
Browse code

doesn't modify params in SafeBuffer#%

  • Loading branch information...
commit 3b1c30c99ff1f3f5e970e3fa696d3291d5897bd7 1 parent 62c6ac2
Vasiliy Ermolovich nashby authored
4 activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -151,9 +151,7 @@ def +(other)
151 151 end
152 152
153 153 def %(args)
154   - args = Array(args)
155   -
156   - args.map! do |arg|
  154 + args = Array(args).map do |arg|
157 155 if !html_safe? || arg.html_safe?
158 156 arg
159 157 else
7 activesupport/test/core_ext/string_ext_test.rb
@@ -463,6 +463,13 @@ def to_s
463 463 assert @other_string.html_safe?
464 464 end
465 465
  466 + test "Concatting with % doesn't modify a string" do
  467 + @other_string = ["<p>", "<b>", "<h1>"]
  468 + "%s %s %s".html_safe % @other_string
  469 +
  470 + assert_equal ["<p>", "<b>", "<h1>"], @other_string
  471 + end
  472 +
466 473 test "Concatting a fixnum to safe always yields safe" do
467 474 string = @string.html_safe
468 475 string = string.concat(13)

0 comments on commit 3b1c30c

Please sign in to comment.
Something went wrong with that request. Please try again.