Files
js-xss/lib/index.js

32 lines
771 B
JavaScript
Raw Normal View History

2014-02-13 14:58:36 +08:00
/**
2017-12-21 14:19:10 +08:00
* xss
2014-02-13 14:58:36 +08:00
*
2017-12-21 14:19:10 +08:00
* @author Zongmin Lei<leizongmin@gmail.com>
2014-02-13 14:58:36 +08:00
*/
2017-12-21 14:22:34 +08:00
var DEFAULT = require("./default");
var parser = require("./parser");
var FilterXSS = require("./xss");
2014-02-13 14:58:36 +08:00
/**
2017-12-21 14:19:10 +08:00
* filter xss function
2014-02-13 14:58:36 +08:00
*
2017-12-21 14:19:10 +08:00
* @param {String} html
* @param {Object} options { whiteList, onTag, onTagAttr, onIgnoreTag, onIgnoreTagAttr, safeAttrValue, escapeHtml }
2014-02-13 14:58:36 +08:00
* @return {String}
*/
2017-12-21 14:22:34 +08:00
function filterXSS(html, options) {
2014-02-13 14:58:36 +08:00
var xss = new FilterXSS(options);
return xss.process(html);
}
exports = module.exports = filterXSS;
exports.FilterXSS = FilterXSS;
for (var i in DEFAULT) exports[i] = DEFAULT[i];
for (var i in parser) exports[i] = parser[i];
2017-12-21 14:19:10 +08:00
// using `xss` on the browser, output `filterXSS` to the globals
2017-12-21 14:22:34 +08:00
if (typeof window !== "undefined") {
2014-02-13 14:58:36 +08:00
window.filterXSS = module.exports;
}