Use the HTML5 Purify extension in ThinkJS
npm install think-purify --save
const purify = require('think-purify')
module.exports = [
purify
];
module.exports = class extends Base {
indexAction() {
const html = this.post('html');
const result = this.purify(html); // Filtering dangerous html tags and attributes
return this.display();
}
};