xss_blade

1.0.1 • Public • Published

xss防御前端过滤工具:基于npm上的xss库简单封装

Using npm:

$ npm i xss_blade --save

简单使用

    import { xssFilter, getDefaultOptions } from "xss_blade";

    html = xssFilter('<script>alert("xss");</script>');

    console.log('默认参数:', getDefaultOptions());

传递第二个参数options来自定义规则,具体规则见 xss 官方文档👍

    options = {
        whiteList:{
            a:['href'],
            img:['src']
        }
    };  // 自定义规则

    options = {
        whiteList:{}
    };  // 覆盖封装函数内的whiteList配置

    html = xssFilter('<script>alert("xssFilter");</script>', options);

Readme

Keywords

none

Package Sidebar

Install

npm i xss_blade

Weekly Downloads

0

Version

1.0.1

License

none

Unpacked Size

2.28 kB

Total Files

3

Last publish

Collaborators

  • spartaattack