我有一个测试字符串。
const html = '{%remove%} useful {{remove}} <svg></p><style><a id="</style><img src=1 onerror=alert(1)>"> keep';
我正在尝试删除所有html内容和 {{,}} , {%,% } 。但我想在字符串上保留有用和保持字样。
const purifyConfig = {
FORBID_TAGS: ['{{', '{%',],
SAFE_FOR_TEMPLATES: true,
RETURN_TRUSTED_TYPE: true,
ALLOW_DATA_ATTR: false,
KEEP_CONTENT: true,
};
const clean = DOMPurify.sanitize(html, purifyConfig);
清除结果为空字符串。 我应该使用什么配置来做到这一点?