Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
52 lines
1.1 KiB
Plaintext
52 lines
1.1 KiB
Plaintext
/**
|
|
* xss
|
|
*
|
|
* @author Zongmin Lei<leizongmin@gmail.com>
|
|
*/
|
|
|
|
var DEFAULT = require("./default");
|
|
var parser = require("./parser");
|
|
var FilterXSS = require("./xss");
|
|
|
|
/**
|
|
* filter xss function
|
|
*
|
|
* @param {String} html
|
|
* @param {Object} options { whiteList, onTag, onTagAttr, onIgnoreTag, onIgnoreTagAttr, safeAttrValue, escapeHtml }
|
|
* @return {String}
|
|
*/
|
|
function filterXSS(html, options) {
|
|
var xss = new FilterXSS(options);
|
|
return xss.process(html);
|
|
}
|
|
|
|
exports = module.exports = filterXSS;
|
|
exports.filterXSS = filterXSS;
|
|
exports.FilterXSS = FilterXSS;
|
|
|
|
(function () {
|
|
for (var i in DEFAULT) {
|
|
exports[i] = DEFAULT[i];
|
|
}
|
|
for (var j in parser) {
|
|
exports[j] = parser[j];
|
|
}
|
|
})();
|
|
|
|
// using `xss` on the browser, output `filterXSS` to the globals
|
|
if (typeof window !== "undefined") {
|
|
window.filterXSS = module.exports;
|
|
}
|
|
|
|
// using `xss` on the WebWorker, output `filterXSS` to the globals
|
|
function isWorkerEnv() {
|
|
return (
|
|
typeof self !== "undefined" &&
|
|
typeof DedicatedWorkerGlobalScope !== "undefined" &&
|
|
self instanceof DedicatedWorkerGlobalScope
|
|
);
|
|
}
|
|
if (isWorkerEnv()) {
|
|
self.filterXSS = module.exports;
|
|
}
|