mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-18 10:20:43 -07:00
fix parsing comment tag delimiter with extra strings
This commit is contained in:
@@ -15,6 +15,8 @@ module Liquid
|
|||||||
# {% endcomment %}
|
# {% endcomment %}
|
||||||
# @liquid_syntax_keyword content The content of the comment.
|
# @liquid_syntax_keyword content The content of the comment.
|
||||||
class Comment < Block
|
class Comment < Block
|
||||||
|
TagDelimiter = /\A(.*)#{TagStart}#{WhitespaceControl}?\s*(endcomment)\s*(.*)?#{WhitespaceControl}?#{TagEnd}\z/om
|
||||||
|
|
||||||
def render_to_output_buffer(_context, output)
|
def render_to_output_buffer(_context, output)
|
||||||
output
|
output
|
||||||
end
|
end
|
||||||
@@ -49,6 +51,9 @@ module Liquid
|
|||||||
next if tag_name_match.nil?
|
next if tag_name_match.nil?
|
||||||
|
|
||||||
tag_name_match[1]
|
tag_name_match[1]
|
||||||
|
elsif TagDelimiter.match?(token)
|
||||||
|
# aggressively match comment delimiter first
|
||||||
|
"endcomment"
|
||||||
else
|
else
|
||||||
tag_name_match = BlockBody::FullTokenPossiblyInvalid.match(token)
|
tag_name_match = BlockBody::FullTokenPossiblyInvalid.match(token)
|
||||||
|
|
||||||
|
|||||||
@@ -107,4 +107,18 @@ class CommentTagUnitTest < Minitest::Test
|
|||||||
|
|
||||||
assert_equal(expected, output)
|
assert_equal(expected, output)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_comment_tag_delimiter_with_extra_strings
|
||||||
|
assert_template_result(
|
||||||
|
'',
|
||||||
|
<<~LIQUID.chomp,
|
||||||
|
{% comment %}
|
||||||
|
{% comment %}
|
||||||
|
{% endcomment
|
||||||
|
{% if true %}
|
||||||
|
{% endif %}
|
||||||
|
{% endcomment %}
|
||||||
|
LIQUID
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user