Shopify / liquid-c

Liquid performance extension in C.
MIT License
119 stars 24 forks source link

Fix parsing raw tag delimiters without spaces #200

Closed ggmichaelgo closed 1 year ago

ggmichaelgo commented 1 year ago

What you trying to solve?

This PR https://github.com/Shopify/liquid-c/pull/199 has broke how Liquid-C parses the raw tag's delimiter without any spaces.

raw tag delimiter like this is raising a syntax error:

{% raw %}123{%endraw%}

How are you solving this issue?

This PR refactored the raw.c's match_full_token_possibly_invalid method. It will search the token from its end to its start, and try to match the tag delimiter that is only made up with a word character, \w.

This refactor also fixes how Liquid-C allows - character before the raw tag's delimiter. In example, these Liquid templates are invalid, and Liquid-C does not raise a syntax error:

require 'liquid'
require 'liquid/c'

Liquid::Template.parse("{% raw %}123{% - endraw %}") # this should raise an error