summaryrefslogtreecommitdiff
path: root/public/js/render.js
blob: 1abb68c52030904b6266211c004c56ee6f51be0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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);
}