Skip to content

Commit 9ff839a

Browse files
committed
chore: sanitize the examples HTML before inserting in db
1 parent 94f4662 commit 9ff839a

File tree

3 files changed

+17898
-2136
lines changed

3 files changed

+17898
-2136
lines changed

api/models/Topic.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
var _ = require('lodash');
99
var Promise = require('bluebird');
10+
var sanitizeHtml = require('sanitize-html');
1011

1112
module.exports = {
1213

@@ -232,6 +233,11 @@ module.exports = {
232233
topic.usage = topic.usage.contents;
233234
}
234235

236+
topic.examples = sanitizeHtml(topic.examples, {
237+
allowedTags: ['a' ],
238+
allowedAttributes: {}
239+
});
240+
235241
var arrayToString = function(val) {
236242
if (val instanceof Array) {
237243
if (_.isEmpty(val)) return '';

0 commit comments

Comments
 (0)