Follow-up to Securing your app together.
My understanding so far:
- Product descriptions and non-app-scoped metafields are untrusted, because any app with
write_productscan write them. - Liquid has no sanitize filter, so untrusted HTML can only be rendered as plain text there (
metafield_text,strip_html | escape). - To keep the formatting, the only option is
{{ product.description | json }}, a sanitizer in JavaScript, and then inserting the result.
Dawn and Horizon output product.description raw, so this affects every store on Shopify’s own themes, not only apps. A theme can’t fix it in Liquid, and the JavaScript route takes the description out of the server-rendered HTML and adds a sanitizer to every product page.
Will this be fixed for Dawn and Horizon as well? Is the plan a Liquid sanitize filter, or sanitizing descriptionHtml when it is written?