fix parsing nested comment tag with extra strings

This commit is contained in:
Michael Go
2023-11-11 12:19:44 -04:00
parent 6dafc19b6d
commit 6a5ebb0e85
2 changed files with 20 additions and 3 deletions
+6 -3
View File
@@ -15,7 +15,7 @@ module Liquid
# {% endcomment %}
# @liquid_syntax_keyword content The content of the comment.
class Comment < Block
TagDelimiter = /\A(.*)#{TagStart}#{WhitespaceControl}?\s*(endcomment)\s*(.*)?#{WhitespaceControl}?#{TagEnd}\z/om
TAG_DELIMITER = /\A(.*)#{TagStart}#{WhitespaceControl}?\s*(endcomment)\s*(.*)?#{WhitespaceControl}?#{TagEnd}\z/om
def render_to_output_buffer(_context, output)
output
@@ -51,9 +51,12 @@ module Liquid
next if tag_name_match.nil?
tag_name_match[1]
elsif TagDelimiter.match?(token)
# aggressively match comment delimiter first
elsif TAG_DELIMITER.match?(token)
# aggressively match comment delimiter
"endcomment"
elsif token =~ BlockBody::FullToken && Regexp.last_match(2) == "comment"
# aggressively match comment tag
"comment"
else
tag_name_match = BlockBody::FullTokenPossiblyInvalid.match(token)