handlebars-helpers icon indicating copy to clipboard operation
handlebars-helpers copied to clipboard

sanitize fails at invalid html

Open Tiggerito opened this issue 4 years ago • 0 comments

I've been using the sanitize helper in BigCommerce to get clean text from html. We just encountered an error that I've narrowed down to an issue with handling invalid html.

Example input:

<p>
before bug<img test"="">after bug
</p>

I've added a deliberate mistake with the syntax of the img attribute, adding a random double quote.

This causes the sanitize to stop at that syntax error and only output text from before it. e.g. "before bug".

It would be nicer if it was more robust.

Tiggerito avatar Sep 19 '20 05:09 Tiggerito