xss.js 687 B

123456789101112131415161718192021222324252627282930
  1. class Xss {
  2. constructor(isAllowAllAttrs) {
  3. const xss = require('xss');
  4. // create the option object
  5. let option = {
  6. stripIgnoreTag: true,
  7. css: false,
  8. escapeHtml: (html) => html, // resolve https://github.com/weseek/growi/issues/221
  9. };
  10. //what is this??????????????????? maybe disable this
  11. if (isAllowAllAttrs) {
  12. // allow all attributes
  13. option.onTagAttr = function(tag, name, value, isWhiteAttr) {
  14. return `${name}="${value}"`;
  15. };
  16. }
  17. // create the XSS Filter instance
  18. this.myxss = new xss.FilterXSS(option);
  19. }
  20. process(markdown) {
  21. return this.myxss.process(markdown);
  22. }
  23. }
  24. module.exports = Xss;