web xss攻击经常使用解决方案

web xss攻击常看法决方案

1.https://jsxss.com/zh/options....html

js-xss能够过滤标签全部的属性 只显示文本

2.标签过滤web

var html = filterXSS(contentValue,{
                    onTag : function (tag, html, options) {
                        console.log(tag, html, options)
                        if (tag === 'script') {
                            return filterXSS(html);
                        } else {
                         // 不对其属性列表进行过滤
                            return html
                        }
                    }
                });

3.白名单过滤xss

var html = filterXSS(contentValue,{
                whiteList: {
                    span: ['style'],
                    div: ['style'],
                    p: ['style'],
                    b: ['style'],
                    strong: ['style']
                }
            });
相关文章
相关标签/搜索