mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Merge pull request #1763 from Shopify/fix-comment-tag-delim-parsing
fix parsing comment tag delimiter
This commit is contained in:
@@ -15,7 +15,7 @@ module Liquid
|
||||
# {% endcomment %}
|
||||
# @liquid_syntax_keyword content The content of the comment.
|
||||
class Comment < Block
|
||||
TAG_DELIMITER = /\A(.*)#{TagStart}#{WhitespaceControl}?\s*(endcomment)\s*(.*)?#{WhitespaceControl}?#{TagEnd}\z/om
|
||||
TAG_DELIMITER = /\A(.*)#{TagStart}#{WhitespaceControl}?\s*(endcomment)\s*(\s.*)?#{WhitespaceControl}?#{TagEnd}\z/om
|
||||
|
||||
def render_to_output_buffer(_context, output)
|
||||
output
|
||||
|
||||
@@ -135,4 +135,24 @@ class CommentTagUnitTest < Minitest::Test
|
||||
LIQUID
|
||||
)
|
||||
end
|
||||
|
||||
def test_ignores_delimiter_with_extra_strings
|
||||
assert_template_result(
|
||||
'',
|
||||
<<~LIQUID.chomp,
|
||||
{% if true %}
|
||||
{% comment %}
|
||||
{% commentXXXXX %}wut{% endcommentXXXXX %}
|
||||
{% endcomment %}
|
||||
{% endif %}
|
||||
LIQUID
|
||||
)
|
||||
end
|
||||
|
||||
def test_delimiter_can_have_extra_strings
|
||||
assert_template_result('', "{% comment %}123{% endcomment xyz %}")
|
||||
assert_template_result('', "{% comment %}123{% endcomment\txyz %}")
|
||||
assert_template_result('', "{% comment %}123{% endcomment\nxyz %}")
|
||||
assert_template_result('', "{% comment %}123{% endcomment\n xyz endcomment %}")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user