Thanks for the useful lib. Unfortunately it is not possible to remove a hook because they are held as global state here:
E.g. if a want to sanitize one html email while removing 'src' attributes from image tags and then for the second html mail, I want to allow images:
// remove sources of image tags to prevent privacy leak during resource fetching
if (removeImages) {
window.DOMPurify.addHook('afterSanitizeAttributes', function(node) {
if ('src' in node) {
node.removeAttribute('src');
}
});
}
// sanitize HTML content: https://github.com/cure53/DOMPurify
html = window.DOMPurify.sanitize(html);
If 'removeImages' is false the second time the hook is still called.