mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 00:55:11 -07:00
Fix #warnings taking exponential time to compute
This commit is contained in:
@@ -62,7 +62,7 @@ module Liquid
|
|||||||
def warnings
|
def warnings
|
||||||
all_warnings = []
|
all_warnings = []
|
||||||
nodelist.each do |node|
|
nodelist.each do |node|
|
||||||
all_warnings.concat(node.warnings) if node.respond_to?(:warnings) && node.warnings
|
all_warnings.concat(node.warnings) if node.respond_to?(:warnings)
|
||||||
end
|
end
|
||||||
all_warnings
|
all_warnings
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,6 +37,16 @@ class TemplateTest < Minitest::Test
|
|||||||
assert_equal 'from instance assigns', t.parse("{{ foo }}").render!
|
assert_equal 'from instance assigns', t.parse("{{ foo }}").render!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_warnings_is_not_exponential_time
|
||||||
|
str = "false"
|
||||||
|
100.times do
|
||||||
|
str = "{% if true %}true{% else %}#{str}{% endif %}"
|
||||||
|
end
|
||||||
|
|
||||||
|
t = Template.parse(str)
|
||||||
|
assert_equal [], t.warnings
|
||||||
|
end
|
||||||
|
|
||||||
def test_instance_assigns_persist_on_same_template_parsing_between_renders
|
def test_instance_assigns_persist_on_same_template_parsing_between_renders
|
||||||
t = Template.new.parse("{{ foo }}{% assign foo = 'foo' %}{{ foo }}")
|
t = Template.new.parse("{{ foo }}{% assign foo = 'foo' %}{{ foo }}")
|
||||||
assert_equal 'foo', t.render!
|
assert_equal 'foo', t.render!
|
||||||
|
|||||||
Reference in New Issue
Block a user