mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
Merge pull request #1769 from Shopify/comment-tag-with-extra-string
fix parsing comment tag with extra string
This commit is contained in:
@@ -15,8 +15,6 @@ 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
|
||||||
TAG_DELIMITER = /\A(.*)#{TagStart}#{WhitespaceControl}?\s*(endcomment)\s*(\s.*)?#{WhitespaceControl}?#{TagEnd}\z/om
|
|
||||||
|
|
||||||
def render_to_output_buffer(_context, output)
|
def render_to_output_buffer(_context, output)
|
||||||
output
|
output
|
||||||
end
|
end
|
||||||
@@ -51,12 +49,9 @@ module Liquid
|
|||||||
next if tag_name_match.nil?
|
next if tag_name_match.nil?
|
||||||
|
|
||||||
tag_name_match[1]
|
tag_name_match[1]
|
||||||
elsif TAG_DELIMITER.match?(token)
|
elsif token =~ BlockBody::FullToken && Regexp.last_match(2) == "comment" || Regexp.last_match(2) == "endcomment"
|
||||||
# aggressively match comment delimiter
|
# aggressively match comment tag or comment tag delimiter
|
||||||
"endcomment"
|
Regexp.last_match(2)
|
||||||
elsif token =~ BlockBody::FullToken && Regexp.last_match(2) == "comment"
|
|
||||||
# aggressively match comment tag
|
|
||||||
"comment"
|
|
||||||
else
|
else
|
||||||
tag_name_match = BlockBody::FullTokenPossiblyInvalid.match(token)
|
tag_name_match = BlockBody::FullTokenPossiblyInvalid.match(token)
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ class CommentTagUnitTest < Minitest::Test
|
|||||||
assert_template_result('', "{% comment %}123{% endcomment\txyz %}")
|
assert_template_result('', "{% comment %}123{% endcomment\txyz %}")
|
||||||
assert_template_result('', "{% comment %}123{% endcomment\nxyz %}")
|
assert_template_result('', "{% comment %}123{% endcomment\nxyz %}")
|
||||||
assert_template_result('', "{% comment %}123{% endcomment\n xyz endcomment %}")
|
assert_template_result('', "{% comment %}123{% endcomment\n xyz endcomment %}")
|
||||||
|
assert_template_result('', "{%comment}{% assign a = 1 %}{%endcomment}{% endif %}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_with_whitespace_control
|
def test_with_whitespace_control
|
||||||
|
|||||||
Reference in New Issue
Block a user