mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00
13 lines
No EOL
526 B
JavaScript
13 lines
No EOL
526 B
JavaScript
function preventXSS(html) {
|
|
var options = {
|
|
allowCommentTag: true,
|
|
onIgnoreTagAttr: function (tag, name, value, isWhiteAttr) {
|
|
// allow attr start with 'data-' or equal 'id' and 'class'
|
|
if (name.substr(0, 5) === 'data-' || name === 'id' || name === 'class') {
|
|
// escape its value using built-in escapeAttrValue function
|
|
return name + '="' + filterXSS.escapeAttrValue(value) + '"';
|
|
}
|
|
}
|
|
};
|
|
return filterXSS(html, options);
|
|
} |