mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 02:40:41 -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 %}
|
# {% 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*(.*)?#{WhitespaceControl}?#{TagEnd}\z/om
|
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
|
||||||
|
|||||||
@@ -135,4 +135,24 @@ class CommentTagUnitTest < Minitest::Test
|
|||||||
LIQUID
|
LIQUID
|
||||||
)
|
)
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user