mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Merge pull request #1350 from Shopify/pz-instrument-invalid-end-tag
Instrument invalid end tags
This commit is contained in:
@@ -77,6 +77,9 @@ module Liquid
|
|||||||
body.parse(tokens, parse_context) do |end_tag_name, end_tag_params|
|
body.parse(tokens, parse_context) do |end_tag_name, end_tag_params|
|
||||||
@blank &&= body.blank?
|
@blank &&= body.blank?
|
||||||
|
|
||||||
|
# Instrument for bug 1346
|
||||||
|
Usage.increment("end_tag_params") if end_tag_params && !end_tag_params.empty?
|
||||||
|
|
||||||
return false if end_tag_name == block_delimiter
|
return false if end_tag_name == block_delimiter
|
||||||
raise_tag_never_closed(block_name) unless end_tag_name
|
raise_tag_never_closed(block_name) unless end_tag_name
|
||||||
|
|
||||||
|
|||||||
@@ -55,4 +55,24 @@ class BlockTest < Minitest::Test
|
|||||||
assert_equal buf.object_id, output.object_id
|
assert_equal buf.object_id, output.object_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_instrument_for_bug_1346
|
||||||
|
calls = []
|
||||||
|
Liquid::Usage.stub(:increment, ->(name) { calls << name }) do
|
||||||
|
Liquid::Template.parse("{% for i in (1..2) %}{{ i }}{% endfor {% foo %}")
|
||||||
|
end
|
||||||
|
assert_equal(["end_tag_params"], calls)
|
||||||
|
|
||||||
|
calls = []
|
||||||
|
Liquid::Usage.stub(:increment, ->(name) { calls << name }) do
|
||||||
|
Liquid::Template.parse("{% for i in (1..2) %}{{ i }}{% endfor test %}")
|
||||||
|
end
|
||||||
|
assert_equal(["end_tag_params"], calls)
|
||||||
|
|
||||||
|
calls = []
|
||||||
|
Liquid::Usage.stub(:increment, ->(name) { calls << name }) do
|
||||||
|
Liquid::Template.parse("{% for i in (1..2) %}{{ i }}{% endfor %}")
|
||||||
|
end
|
||||||
|
assert_equal([], calls)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user