HtmlSanitizer
HtmlSanitizer copied to clipboard
Error whenn _tagWhitelist missing BODY
i want to have a very restrictive tag list
const _tagWhitelist = { 'A': true, 'B': true, 'BODY': true, 'BR': true, };
but if i remove 'BODY': true,
i get an javascript error in console saying
Uncaught TypeError: resultElement.innerHTML is undefined
Maybe a workaround: put body in the content tag white list. (list of tags to replace with DIVs)
This code, in a middle step, turns the input HTML string into a little mini-document with to-be-filtered DOM in its body, even if your HTML string didn't have a body. So when you ask it to ignore body elements, it basically ignores everything.
(Disclaimer: I didn't actually try this workaround; I was doing enough weird stuff such that I ended up writing new code inspired by this. I remember that I needed to handle bodies specially, though)