提交 724707ed 编写于 作者: R Rafael Mendonça França

Merge pull request #18236 from vipulnsward/dont-eval-frozen

Fix html_safe string access modifying frozen values
......@@ -150,7 +150,9 @@ def [](*args)
else
if html_safe?
new_safe_buffer = super
new_safe_buffer.instance_variable_set :@html_safe, true
unless new_safe_buffer.respond_to?(:frozen?) && new_safe_buffer.frozen?
new_safe_buffer.instance_variable_set :@html_safe, true
end
new_safe_buffer
else
to_str[*args]
......
......@@ -165,4 +165,13 @@ def test_titleize
x = 'foo %{x} bar'.html_safe % { x: 'qux' }
assert x.html_safe?, 'should be safe'
end
test 'Should not affect frozen objects when accessing characters' do
x = 'Hello'.html_safe
assert_nothing_raised do
x[/a/, 1]
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册