提交 3b1c30c9 编写于 作者: V Vasiliy Ermolovich

doesn't modify params in SafeBuffer#%

上级 62c6ac2f
...@@ -151,9 +151,7 @@ def +(other) ...@@ -151,9 +151,7 @@ def +(other)
end end
def %(args) def %(args)
args = Array(args) args = Array(args).map do |arg|
args.map! do |arg|
if !html_safe? || arg.html_safe? if !html_safe? || arg.html_safe?
arg arg
else else
......
...@@ -463,6 +463,13 @@ def to_s ...@@ -463,6 +463,13 @@ def to_s
assert @other_string.html_safe? assert @other_string.html_safe?
end end
test "Concatting with % doesn't modify a string" do
@other_string = ["<p>", "<b>", "<h1>"]
"%s %s %s".html_safe % @other_string
assert_equal ["<p>", "<b>", "<h1>"], @other_string
end
test "Concatting a fixnum to safe always yields safe" do test "Concatting a fixnum to safe always yields safe" do
string = @string.html_safe string = @string.html_safe
string = string.concat(13) string = string.concat(13)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册