diff --git a/dist/xss.js b/dist/xss.js index ab60eda..d920ff2 100644 --- a/dist/xss.js +++ b/dist/xss.js @@ -479,7 +479,11 @@ if (typeof window !== "undefined") { // using `xss` on the WebWorker, output `filterXSS` to the globals function isWorkerEnv() { - return typeof self !== 'undefined' && typeof DedicatedWorkerGlobalScope !== 'undefined' && self instanceof DedicatedWorkerGlobalScope; + return ( + typeof self !== "undefined" && + typeof DedicatedWorkerGlobalScope !== "undefined" && + self instanceof DedicatedWorkerGlobalScope + ); } if (isWorkerEnv()) { self.filterXSS = module.exports; @@ -573,11 +577,11 @@ function parseTag(html, onTag, escapeHtml) { tagStart = false; continue; } - if ((c === '"' || c === "'")) { + if (c === '"' || c === "'") { var i = 1; var ic = html.charAt(currentPos - i); - while ((ic.trim() === "") || (ic === "=")) { + while (ic.trim() === "" || ic === "=") { if (ic === "=") { quoteStart = c; continue chariterator; @@ -736,7 +740,7 @@ exports.parseAttr = parseAttr; },{"./util":4}],4:[function(require,module,exports){ module.exports = { - indexOf: function(arr, item) { + indexOf: function (arr, item) { var i, j; if (Array.prototype.indexOf) { return arr.indexOf(item); @@ -748,7 +752,7 @@ module.exports = { } return -1; }, - forEach: function(arr, fn, scope) { + forEach: function (arr, fn, scope) { var i, j; if (Array.prototype.forEach) { return arr.forEach(fn, scope); @@ -757,17 +761,17 @@ module.exports = { fn.call(scope, arr[i], i, arr); } }, - trim: function(str) { + trim: function (str) { if (String.prototype.trim) { return str.trim(); } return str.replace(/(^\s*)|(\s*$)/g, ""); }, - spaceIndex: function(str) { + spaceIndex: function (str) { var reg = /\s|\n|\t/; var match = reg.exec(str); return match ? match.index : -1; - } + }, }; },{}],5:[function(require,module,exports){ @@ -807,7 +811,7 @@ function getAttrs(html) { if (i === -1) { return { html: "", - closing: html[html.length - 2] === "/" + closing: html[html.length - 2] === "/", }; } html = _.trim(html.slice(i + 1, -1)); @@ -815,7 +819,7 @@ function getAttrs(html) { if (isClosing) html = _.trim(html.slice(0, -1)); return { html: html, - closing: isClosing + closing: isClosing, }; } @@ -877,7 +881,7 @@ function FilterXSS(options) { * @param {String} html * @return {String} */ -FilterXSS.prototype.process = function(html) { +FilterXSS.prototype.process = function (html) { // compatible with the input html = html || ""; html = html.toString(); @@ -916,12 +920,12 @@ FilterXSS.prototype.process = function(html) { var retHtml = parseTag( html, - function(sourcePosition, position, tag, html, isClosing) { + function (sourcePosition, position, tag, html, isClosing) { var info = { sourcePosition: sourcePosition, position: position, isClosing: isClosing, - isWhite: whiteList.hasOwnProperty(tag) + isWhite: whiteList.hasOwnProperty(tag), }; // call `onTag()` @@ -935,7 +939,7 @@ FilterXSS.prototype.process = function(html) { var attrs = getAttrs(html); var whiteAttrList = whiteList[tag]; - var attrsHtml = parseAttr(attrs.html, function(name, value) { + var attrsHtml = parseAttr(attrs.html, function (name, value) { // call `onTagAttr()` var isWhiteAttr = _.indexOf(whiteAttrList, name) !== -1; var ret = onTagAttr(tag, name, value, isWhiteAttr); diff --git a/lib/cli.js b/lib/cli.js index 4aa075e..0f3b062 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -9,7 +9,7 @@ var readline = require("readline"); var rl = readline.createInterface({ input: process.stdin, - output: process.stdout + output: process.stdout, }); console.log('Enter a blank line to do xss(), enter "@quit" to exit.\n'); @@ -31,7 +31,7 @@ function setPrompt(line) { setPrompt(1); var html = []; -rl.on("line", function(line) { +rl.on("line", function (line) { if (line === "@quit") return process.exit(); if (line === "") { console.log(""); diff --git a/lib/index.js b/lib/index.js index e0c1a06..9a5eea4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -33,7 +33,11 @@ if (typeof window !== "undefined") { // using `xss` on the WebWorker, output `filterXSS` to the globals function isWorkerEnv() { - return typeof self !== 'undefined' && typeof DedicatedWorkerGlobalScope !== 'undefined' && self instanceof DedicatedWorkerGlobalScope; + return ( + typeof self !== "undefined" && + typeof DedicatedWorkerGlobalScope !== "undefined" && + self instanceof DedicatedWorkerGlobalScope + ); } if (isWorkerEnv()) { self.filterXSS = module.exports; diff --git a/lib/parser.js b/lib/parser.js index 82c6a29..c3a07d2 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -85,11 +85,11 @@ function parseTag(html, onTag, escapeHtml) { tagStart = false; continue; } - if ((c === '"' || c === "'")) { + if (c === '"' || c === "'") { var i = 1; var ic = html.charAt(currentPos - i); - while ((ic.trim() === "") || (ic === "=")) { + while (ic.trim() === "" || ic === "=") { if (ic === "=") { quoteStart = c; continue chariterator; diff --git a/lib/util.js b/lib/util.js index 1dcd7fa..8f4b35e 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,5 +1,5 @@ module.exports = { - indexOf: function(arr, item) { + indexOf: function (arr, item) { var i, j; if (Array.prototype.indexOf) { return arr.indexOf(item); @@ -11,7 +11,7 @@ module.exports = { } return -1; }, - forEach: function(arr, fn, scope) { + forEach: function (arr, fn, scope) { var i, j; if (Array.prototype.forEach) { return arr.forEach(fn, scope); @@ -20,15 +20,15 @@ module.exports = { fn.call(scope, arr[i], i, arr); } }, - trim: function(str) { + trim: function (str) { if (String.prototype.trim) { return str.trim(); } return str.replace(/(^\s*)|(\s*$)/g, ""); }, - spaceIndex: function(str) { + spaceIndex: function (str) { var reg = /\s|\n|\t/; var match = reg.exec(str); return match ? match.index : -1; - } + }, }; diff --git a/lib/xss.js b/lib/xss.js index 74d2e42..2b3f363 100644 --- a/lib/xss.js +++ b/lib/xss.js @@ -34,7 +34,7 @@ function getAttrs(html) { if (i === -1) { return { html: "", - closing: html[html.length - 2] === "/" + closing: html[html.length - 2] === "/", }; } html = _.trim(html.slice(i + 1, -1)); @@ -42,7 +42,7 @@ function getAttrs(html) { if (isClosing) html = _.trim(html.slice(0, -1)); return { html: html, - closing: isClosing + closing: isClosing, }; } @@ -104,7 +104,7 @@ function FilterXSS(options) { * @param {String} html * @return {String} */ -FilterXSS.prototype.process = function(html) { +FilterXSS.prototype.process = function (html) { // compatible with the input html = html || ""; html = html.toString(); @@ -143,12 +143,12 @@ FilterXSS.prototype.process = function(html) { var retHtml = parseTag( html, - function(sourcePosition, position, tag, html, isClosing) { + function (sourcePosition, position, tag, html, isClosing) { var info = { sourcePosition: sourcePosition, position: position, isClosing: isClosing, - isWhite: whiteList.hasOwnProperty(tag) + isWhite: whiteList.hasOwnProperty(tag), }; // call `onTag()` @@ -162,7 +162,7 @@ FilterXSS.prototype.process = function(html) { var attrs = getAttrs(html); var whiteAttrList = whiteList[tag]; - var attrsHtml = parseAttr(attrs.html, function(name, value) { + var attrsHtml = parseAttr(attrs.html, function (name, value) { // call `onTagAttr()` var isWhiteAttr = _.indexOf(whiteAttrList, name) !== -1; var ret = onTagAttr(tag, name, value, isWhiteAttr); diff --git a/typings/xss-tests.ts b/typings/xss-tests.ts index 744147c..9885d0c 100644 --- a/typings/xss-tests.ts +++ b/typings/xss-tests.ts @@ -21,7 +21,7 @@ console.log( onTag(tag: string, html: string, options: {}): string { return html; }, - css: false + css: false, }) ); @@ -34,7 +34,7 @@ xss.filterXSS("hello", { onTag(tag, html, options) { return html; }, - onIgnoreTag(tag, html) {} + onIgnoreTag(tag, html) {}, }); interface ICustomWhiteList extends XSS.IWhiteList {