Shopify / theme-check

The Ultimate Shopify Theme Linter
Other
337 stars 95 forks source link

Prevent bad render tags from passing theme-check #551

Closed catlee closed 2 years ago

catlee commented 2 years ago

The current regex for the liquid tag allows liquid like {% render ‘foo’ %} (note the unicode quote characters) to be accepted.

This PR ensures that the render tag in theme-check only accepts valid render tag expressions.

See also https://github.com/Shopify/shopify/issues/329619 (private)

charlespwd commented 2 years ago

Given that this is code we ported from SFR, did we fix it there too?

catlee commented 2 years ago

Given that this is code we ported from SFR, did we fix it there too?

It no longer raises a SyntaxError in SFR, and instead renders an inline error. We're going to update the validations in core to prevent this format from being saved in themes.

charlespwd commented 2 years ago

We'll have to reopen this @catlee. This was breaking on dawn:

sections/apps.liquid:3: error: UndefinedObject: Undefined object `b`.
    {% render block %}
       ^^^^^^^^^^^^^

sections/featured-product.liquid:85: error: UndefinedObject: Undefined object `b`.
    {% render block %}
       ^^^^^^^^^^^^^

sections/main-article.liquid:8: error: UndefinedObject: Undefined object `b`.
    {% render block %}
       ^^^^^^^^^^^^^

sections/main-cart-footer.liquid:20: error: UndefinedObject: Undefined object `b`.
    {% render block %}
       ^^^^^^^^^^^^^

sections/main-product.liquid:194: error: UndefinedObject: Undefined object `b`.
    {% render block %}
       ^^^^^^^^^^^^^

sections/newsletter.liquid:23: error: UndefinedObject: Undefined object `b`.
    {% render block %}