Files
js-xss/lib/index.js

35 lines
775 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
*/
var DEFAULT = require('./default');
var parser = require('./parser');
var FilterXSS = require('./xss');
/**
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}
*/
function filterXSS (html, options) {
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
2014-02-13 14:58:36 +08:00
if (typeof window !== 'undefined') {
window.filterXSS = module.exports;
}