html-parser icon indicating copy to clipboard operation
html-parser copied to clipboard

`sanitize` should use a whitelist, not a blacklist

Open feross opened this issue 12 years ago • 1 comments

It's a lot easier, safer, and future-proof to specify just the tags that you want to allow, instead of everything to disallow.

For example, 'onclick', 'onerror', 'onhover', 'onmouseover'... are there other attributes I'm missing? Does Gecko/Webkit/Blink have other proprietary events I need to blacklist to protect users of those browsers?

feross avatar Sep 20 '13 23:09 feross

Realized that I can pass a function to sanitize and do return !whitelist(name). Still, would be better to encourage people to use a whitelist.

feross avatar Sep 20 '13 23:09 feross