style: reformat all source code by prettier
This commit is contained in:
18
dist/xss.js
vendored
18
dist/xss.js
vendored
@@ -479,7 +479,11 @@ if (typeof window !== "undefined") {
|
|||||||
|
|
||||||
// using `xss` on the WebWorker, output `filterXSS` to the globals
|
// using `xss` on the WebWorker, output `filterXSS` to the globals
|
||||||
function isWorkerEnv() {
|
function isWorkerEnv() {
|
||||||
return typeof self !== 'undefined' && typeof DedicatedWorkerGlobalScope !== 'undefined' && self instanceof DedicatedWorkerGlobalScope;
|
return (
|
||||||
|
typeof self !== "undefined" &&
|
||||||
|
typeof DedicatedWorkerGlobalScope !== "undefined" &&
|
||||||
|
self instanceof DedicatedWorkerGlobalScope
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (isWorkerEnv()) {
|
if (isWorkerEnv()) {
|
||||||
self.filterXSS = module.exports;
|
self.filterXSS = module.exports;
|
||||||
@@ -573,11 +577,11 @@ function parseTag(html, onTag, escapeHtml) {
|
|||||||
tagStart = false;
|
tagStart = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((c === '"' || c === "'")) {
|
if (c === '"' || c === "'") {
|
||||||
var i = 1;
|
var i = 1;
|
||||||
var ic = html.charAt(currentPos - i);
|
var ic = html.charAt(currentPos - i);
|
||||||
|
|
||||||
while ((ic.trim() === "") || (ic === "=")) {
|
while (ic.trim() === "" || ic === "=") {
|
||||||
if (ic === "=") {
|
if (ic === "=") {
|
||||||
quoteStart = c;
|
quoteStart = c;
|
||||||
continue chariterator;
|
continue chariterator;
|
||||||
@@ -767,7 +771,7 @@ module.exports = {
|
|||||||
var reg = /\s|\n|\t/;
|
var reg = /\s|\n|\t/;
|
||||||
var match = reg.exec(str);
|
var match = reg.exec(str);
|
||||||
return match ? match.index : -1;
|
return match ? match.index : -1;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
},{}],5:[function(require,module,exports){
|
},{}],5:[function(require,module,exports){
|
||||||
@@ -807,7 +811,7 @@ function getAttrs(html) {
|
|||||||
if (i === -1) {
|
if (i === -1) {
|
||||||
return {
|
return {
|
||||||
html: "",
|
html: "",
|
||||||
closing: html[html.length - 2] === "/"
|
closing: html[html.length - 2] === "/",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
html = _.trim(html.slice(i + 1, -1));
|
html = _.trim(html.slice(i + 1, -1));
|
||||||
@@ -815,7 +819,7 @@ function getAttrs(html) {
|
|||||||
if (isClosing) html = _.trim(html.slice(0, -1));
|
if (isClosing) html = _.trim(html.slice(0, -1));
|
||||||
return {
|
return {
|
||||||
html: html,
|
html: html,
|
||||||
closing: isClosing
|
closing: isClosing,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -921,7 +925,7 @@ FilterXSS.prototype.process = function(html) {
|
|||||||
sourcePosition: sourcePosition,
|
sourcePosition: sourcePosition,
|
||||||
position: position,
|
position: position,
|
||||||
isClosing: isClosing,
|
isClosing: isClosing,
|
||||||
isWhite: whiteList.hasOwnProperty(tag)
|
isWhite: whiteList.hasOwnProperty(tag),
|
||||||
};
|
};
|
||||||
|
|
||||||
// call `onTag()`
|
// call `onTag()`
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var readline = require("readline");
|
|||||||
|
|
||||||
var rl = readline.createInterface({
|
var rl = readline.createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
output: process.stdout
|
output: process.stdout,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Enter a blank line to do xss(), enter "@quit" to exit.\n');
|
console.log('Enter a blank line to do xss(), enter "@quit" to exit.\n');
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ if (typeof window !== "undefined") {
|
|||||||
|
|
||||||
// using `xss` on the WebWorker, output `filterXSS` to the globals
|
// using `xss` on the WebWorker, output `filterXSS` to the globals
|
||||||
function isWorkerEnv() {
|
function isWorkerEnv() {
|
||||||
return typeof self !== 'undefined' && typeof DedicatedWorkerGlobalScope !== 'undefined' && self instanceof DedicatedWorkerGlobalScope;
|
return (
|
||||||
|
typeof self !== "undefined" &&
|
||||||
|
typeof DedicatedWorkerGlobalScope !== "undefined" &&
|
||||||
|
self instanceof DedicatedWorkerGlobalScope
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (isWorkerEnv()) {
|
if (isWorkerEnv()) {
|
||||||
self.filterXSS = module.exports;
|
self.filterXSS = module.exports;
|
||||||
|
|||||||
@@ -85,11 +85,11 @@ function parseTag(html, onTag, escapeHtml) {
|
|||||||
tagStart = false;
|
tagStart = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((c === '"' || c === "'")) {
|
if (c === '"' || c === "'") {
|
||||||
var i = 1;
|
var i = 1;
|
||||||
var ic = html.charAt(currentPos - i);
|
var ic = html.charAt(currentPos - i);
|
||||||
|
|
||||||
while ((ic.trim() === "") || (ic === "=")) {
|
while (ic.trim() === "" || ic === "=") {
|
||||||
if (ic === "=") {
|
if (ic === "=") {
|
||||||
quoteStart = c;
|
quoteStart = c;
|
||||||
continue chariterator;
|
continue chariterator;
|
||||||
|
|||||||
@@ -30,5 +30,5 @@ module.exports = {
|
|||||||
var reg = /\s|\n|\t/;
|
var reg = /\s|\n|\t/;
|
||||||
var match = reg.exec(str);
|
var match = reg.exec(str);
|
||||||
return match ? match.index : -1;
|
return match ? match.index : -1;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function getAttrs(html) {
|
|||||||
if (i === -1) {
|
if (i === -1) {
|
||||||
return {
|
return {
|
||||||
html: "",
|
html: "",
|
||||||
closing: html[html.length - 2] === "/"
|
closing: html[html.length - 2] === "/",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
html = _.trim(html.slice(i + 1, -1));
|
html = _.trim(html.slice(i + 1, -1));
|
||||||
@@ -42,7 +42,7 @@ function getAttrs(html) {
|
|||||||
if (isClosing) html = _.trim(html.slice(0, -1));
|
if (isClosing) html = _.trim(html.slice(0, -1));
|
||||||
return {
|
return {
|
||||||
html: html,
|
html: html,
|
||||||
closing: isClosing
|
closing: isClosing,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ FilterXSS.prototype.process = function(html) {
|
|||||||
sourcePosition: sourcePosition,
|
sourcePosition: sourcePosition,
|
||||||
position: position,
|
position: position,
|
||||||
isClosing: isClosing,
|
isClosing: isClosing,
|
||||||
isWhite: whiteList.hasOwnProperty(tag)
|
isWhite: whiteList.hasOwnProperty(tag),
|
||||||
};
|
};
|
||||||
|
|
||||||
// call `onTag()`
|
// call `onTag()`
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ console.log(
|
|||||||
onTag(tag: string, html: string, options: {}): string {
|
onTag(tag: string, html: string, options: {}): string {
|
||||||
return html;
|
return html;
|
||||||
},
|
},
|
||||||
css: false
|
css: false,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ xss.filterXSS("hello", {
|
|||||||
onTag(tag, html, options) {
|
onTag(tag, html, options) {
|
||||||
return html;
|
return html;
|
||||||
},
|
},
|
||||||
onIgnoreTag(tag, html) {}
|
onIgnoreTag(tag, html) {},
|
||||||
});
|
});
|
||||||
|
|
||||||
interface ICustomWhiteList extends XSS.IWhiteList {
|
interface ICustomWhiteList extends XSS.IWhiteList {
|
||||||
|
|||||||
Reference in New Issue
Block a user