Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Recommend escaping strings that can contain user-typed HTML #407

Open
willbroderick opened this issue Nov 1, 2022 · 0 comments

Comments

@willbroderick
Copy link

I would love to see Theme Check recommend escaping all user-entered plain text (with | escape)
I see a lot of developers not escaping strings in Liquid {{ ... }} output.

The information that would tell us which Liquid object properties need escaping is not available in any form. So this may be a large task.

I can see this needing:

  1. A maintained list of Liquid object properties that need escaping. I don't know if Shopify could take this on.
  2. A method of identifying when these properties are being output onto the page (taking into account assignment, loops, etc).

There are many examples of this issue in the current version of Dawn.

If you enter a Discount with the name This <is> a discount, any page on which the discount shows will contain the HTML tag <is> when output:
https://github.com/Shopify/dawn/blob/627bb72c748cb02e905d5972e41c7e4a0cccd620/sections/main-order.liquid#L237
I don't believe this is desired.

An HTML attribute example:
https://github.com/Shopify/dawn/blob/acff8d7c6be60f7d2ec220ca1a21be2c619ff633/snippets/facets.liquid#L116

Enter a double-quote into a value that displays in a facet filter (like a distance - 6"), and the HTML becomes broken.

This occurs in a large number of places in Dawn and other themes. Theme Check would be a great tool for enforcing good practices here.

@lukeh-shopify lukeh-shopify transferred this issue from Shopify/theme-check Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants