From e24e92f342874848403ee14bf09597b61441a77c Mon Sep 17 00:00:00 2001 From: leizongmin Date: Wed, 19 Sep 2012 20:28:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0defa2e..b17a258 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,8 @@ xss.onTagAttr = function (tag, attr, vaule) { // tag:当前标签名(小写) // attr:当前属性名(小写) // value:当前属性值 - // 返回新的属性值,如果想使用默认的处理方式,不返回任何值即可 + // 返回新的属性值,如果想使用默认的处理方式,不返回任何值即可 + // 比如把属性值中的双引号替换为&quote;:return value.replace(/"/g, '&quote;'); }; // 自定义处理不在白名单中的标签 @@ -45,6 +46,7 @@ xss.onIgnoreTag = function (tag, html) { // tag:当前标签名(小写),如:a // html:当前标签的HTML代码,如: // 返回新的标签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('', options); console.log(html);