mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -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 %}
|
||||
# @liquid_syntax_keyword content The content of the comment.
|
||||
class Comment < Block
|
||||
TAG_DELIMITER = /\A(.*)#{TagStart}#{WhitespaceControl}?\s*(endcomment)\s*(\s.*)?#{WhitespaceControl}?#{TagEnd}\z/om
|
||||
|
||||
def render_to_output_buffer(_context, output)
|
||||
output
|
||||
end
|
||||
@@ -51,12 +49,9 @@ module Liquid
|
||||
next if tag_name_match.nil?
|
||||
|
||||
tag_name_match[1]
|
||||
elsif TAG_DELIMITER.match?(token)
|
||||
# aggressively match comment delimiter
|
||||
"endcomment"
|
||||
elsif token =~ BlockBody::FullToken && Regexp.last_match(2) == "comment"
|
||||
# aggressively match comment tag
|
||||
"comment"
|
||||
elsif token =~ BlockBody::FullToken && Regexp.last_match(2) == "comment" || Regexp.last_match(2) == "endcomment"
|
||||
# aggressively match comment tag or comment tag delimiter
|
||||
Regexp.last_match(2)
|
||||
else
|
||||
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\nxyz %}")
|
||||
assert_template_result('', "{% comment %}123{% endcomment\n xyz endcomment %}")
|
||||
assert_template_result('', "{%comment}{% assign a = 1 %}{%endcomment}{% endif %}")
|
||||
end
|
||||
|
||||
def test_with_whitespace_control
|
||||
|
||||
Reference in New Issue
Block a user