Shopify / liquid

Liquid markup language. Safe, customer facing template language for flexible web apps.
https://shopify.github.io/liquid/
MIT License
11.13k stars 1.39k forks source link

fix parsing comment tag delimiter #1763

Closed ggmichaelgo closed 11 months ago

ggmichaelgo commented 11 months ago

What are you trying to solve?

https://github.com/Shopify/liquid/pull/1755 introduced a bug to comment tag parsing.

The comment tag uses this regex to match the tag delimiter:

 /\A(.*)(?-mix:\{\%)-?\s*(endcomment)\s*(.*)?-?(?-mix:\%\})\z/m

After matching the endcomment, the regex is also matching the extra string with \s*(.*)? Since it doesn't require a whitespace after matching with the tag delimiter, it allows delimiters like {% endcommentABC %} to be matched.