Permalink
Browse files

v0.3.3

  • Loading branch information...
1 parent 3ecf854 commit 18e0258ff2d9ecfd8bc99e83cc0c52ea8a28caea @leizongmin committed Dec 20, 2016
Showing with 31 additions and 4 deletions.
  1. +29 −2 dist/xss.js
  2. +1 −1 dist/xss.min.js
  3. +1 −1 package.json
View
@@ -771,6 +771,20 @@ function getAttrs (html) {
}
/**
+ * 浅拷贝对象
+ *
+ * @param {Object} obj
+ * @return {Object}
+ */
+function shallowCopyObject (obj) {
+ var ret = {};
+ for (var i in obj) {
+ ret[i] = obj[i];
+ }
+ return ret;
+}
+
+/**
* XSS过滤对象
*
* @param {Object} options
@@ -780,7 +794,7 @@ function getAttrs (html) {
* css{whiteList, onAttr, onIgnoreAttr} css=false表示禁用cssfilter
*/
function FilterXSS (options) {
- options = options || {};
+ options = shallowCopyObject(options || {});
if (options.stripIgnoreTag) {
if (options.onIgnoreTag) {
@@ -941,6 +955,19 @@ function isNull (obj) {
return (obj === undefined || obj === null);
}
+/**
+ * 浅拷贝对象
+ *
+ * @param {Object} obj
+ * @return {Object}
+ */
+function shallowCopyObject (obj) {
+ var ret = {};
+ for (var i in obj) {
+ ret[i] = obj[i];
+ }
+ return ret;
+}
/**
* 创建CSS过滤器
@@ -951,7 +978,7 @@ function isNull (obj) {
* - {Object} onIgnoreAttr
*/
function FilterCSS (options) {
- options = options || {};
+ options = shallowCopyObject(options || {});
options.whiteList = options.whiteList || DEFAULT.whiteList;
options.onAttr = options.onAttr || DEFAULT.onAttr;
options.onIgnoreAttr = options.onIgnoreAttr || DEFAULT.onIgnoreAttr;
Oops, something went wrong.

0 comments on commit 18e0258

Please sign in to comment.