Skip to content

Commit

Permalink
allow incomplete tags inside a comment tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ggmichaelgo committed Nov 8, 2023
1 parent a681e73 commit afa5f26
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/liquid/block_body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Liquid
class BlockBody
LiquidTagToken = /\A\s*(#{TagName})\s*(.*?)\z/o
FullToken = /\A#{TagStart}#{WhitespaceControl}?(\s*)(#{TagName})(\s*)(.*?)#{WhitespaceControl}?#{TagEnd}\z/om
FullTokenPossiblyInvalid = /\A(.*)#{TagStart}#{WhitespaceControl}?\s*(\w+)\s*(.*)?#{WhitespaceControl}?#{TagEnd}\z/om
ContentOfVariable = /\A#{VariableStart}#{WhitespaceControl}?(.*?)#{WhitespaceControl}?#{VariableEnd}\z/om
WhitespaceOrNothing = /\A\s*\z/
TAGSTART = "{%"
Expand Down
2 changes: 1 addition & 1 deletion lib/liquid/tags/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def parse_body(body, tokens)
# The children tag doesn't require to be a valid Liquid except the comment and raw tag.
# The child comment and raw tag must be closed.
while (token = tokens.send(:shift))
tag_name_match = BlockBody::FullToken.match(token)
tag_name_match = BlockBody::FullTokenPossiblyInvalid.match(token)

next if tag_name_match.nil?

Expand Down
3 changes: 1 addition & 2 deletions lib/liquid/tags/raw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module Liquid
# @liquid_syntax_keyword expression The expression to be output without being rendered.
class Raw < Block
Syntax = /\A\s*\z/
FullTokenPossiblyInvalid = /\A(.*)#{TagStart}#{WhitespaceControl}?\s*(\w+)\s*(.*)?#{WhitespaceControl}?#{TagEnd}\z/om

def initialize(tag_name, markup, parse_context)
super
Expand All @@ -25,7 +24,7 @@ def initialize(tag_name, markup, parse_context)
def parse(tokens)
@body = +''
while (token = tokens.shift)
if token =~ FullTokenPossiblyInvalid && block_delimiter == Regexp.last_match(2)
if token =~ BlockBody::FullTokenPossiblyInvalid && block_delimiter == Regexp.last_match(2)
parse_context.trim_whitespace = (token[-3] == WhitespaceControl)
@body << Regexp.last_match(1) if Regexp.last_match(1) != ""
return
Expand Down

0 comments on commit afa5f26

Please sign in to comment.