leizongmin / js-xss

Sanitize untrusted HTML (to prevent XSS) with a configuration specified by a Whitelist
http://jsxss.com
Other
5.21k stars 630 forks source link

一样的过滤选项及内容,开发环境和编译后的输出有区别,编译后的第一个标签的起始标签被转义了 #240

Open alvawu opened 3 years ago

alvawu commented 3 years ago

一样的过滤选项及内容,开发环境和编译后的输出有区别,编译后的第一个白名单标签的起始标签被转义了

        xss(html, {
            whiteList: {
                h1: ['class'],
                p: ['class'],
                box: ['class'],
                br: [],
                table: ['cellpadding', 'cellspacing'],
                tbody: [],
                tr: [],
                td: ['width', 'style', 'align'],
                th: ['width'],
                span: ['class', 'style'],
                div: ['class']
            },
            css: {
                whiteList: {
                    color: true
                }
            }
        })

html内容: image

开发环境正常返回,但build了以后,输出变成了: image

leizongmin commented 2 years ago

这里看起来是后面一个结果中,<h1> 不在白名单中,所以<> 被转义了。

Lrunlin commented 2 years ago

在白名单的第一个是填写了h1标签的

leizongmin commented 2 years ago

相同的 xss 模块版本和相同的配置,输出结果肯定是一样的,建议再检查一下。