Add taint warnings to the context rather than the template.

This commit is contained in:
Dylan Thacker-Smith
2015-07-07 15:53:02 -04:00
parent 15974d9168
commit 80b6ac3bc7
3 changed files with 18 additions and 8 deletions
+4 -2
View File
@@ -124,8 +124,10 @@ class DropsTest < Minitest::Test
def test_rendering_warns_on_tainted_attr
with_taint_mode(:warn) do
tpl = Liquid::Template.parse('{{ product.user_input }}')
tpl.render!('product' => ProductDrop.new)
assert_match /tainted/, tpl.warnings.first
context = Context.new('product' => ProductDrop.new)
tpl.render!(context)
assert_equal [Liquid::TaintedError], context.warnings.map(&:class)
assert_equal "variable 'product.user_input' is tainted and was not escaped", context.warnings.first.to_s(false)
end
end