更新README
This commit is contained in:
@@ -38,6 +38,7 @@ xss.onTagAttr = function (tag, attr, vaule) {
|
||||
// attr:当前属性名(小写)
|
||||
// value:当前属性值
|
||||
// 返回新的属性值,如果想使用默认的处理方式,不返回任何值即可
|
||||
// 比如把属性值中的双引号替换为&quote;:return value.replace(/"/g, '&quote;');
|
||||
};
|
||||
|
||||
// 自定义处理不在白名单中的标签
|
||||
@@ -45,6 +46,7 @@ xss.onIgnoreTag = function (tag, html) {
|
||||
// tag:当前标签名(小写),如:a
|
||||
// html:当前标签的HTML代码,如:<a href="ooxx">
|
||||
// 返回新的标签HTML代码,如果想使用默认的处理方式,不返回任何值即可
|
||||
// 比如将标签替换为[removed]:return '[removed]';
|
||||
}
|
||||
```
|
||||
|
||||
@@ -52,9 +54,9 @@ xss.onIgnoreTag = function (tag, html) {
|
||||
|
||||
```javascript
|
||||
var options = {
|
||||
whiteList: {}, // 若不指定,则使用默认配置
|
||||
onTagAttr: function () {}, // 若不指定,则使用默认配置
|
||||
onIgnoreTag: function () {} // 若不指定,则使用默认配置
|
||||
whiteList: {}, // 若不指定则使用默认配置,可参考xss.whiteList
|
||||
onTagAttr: function () {}, // 若不指定则使用默认配置,可参考xss.onTagAttr
|
||||
onIgnoreTag: function () {} // 若不指定则使用默认配置,可参考xss.onIgnoreTag
|
||||
};
|
||||
var html = xss('<script>alert("xss");</script>', options);
|
||||
console.log(html);
|
||||
|
||||
Reference in New Issue
Block a user