Skip to content

Commit 17ca35a

Browse files
added xss cleanup on comments
1 parent 7f9ecb6 commit 17ca35a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server/services/comments/comments.hooks.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const createExcerpt = require('../../hooks/create-excerpt');
1111
const createNotifications = require('./hooks/create-notifications');
1212
const createMentionNotifications = require('./hooks/create-mention-notifications');
1313
const _ = require('lodash');
14+
const xss = require('../../hooks/xss');
1415

1516
const userSchema = {
1617
include: {
@@ -21,10 +22,14 @@ const userSchema = {
2122
}
2223
};
2324

25+
const xssFields = ['content', 'contentExcerpt'];
26+
2427
//ToDo: Only let users create comments for contributions they are allowed to
2528
module.exports = {
2629
before: {
27-
all: [],
30+
all: [
31+
xss({ fields: xssFields })
32+
],
2833
find: [],
2934
get: [],
3035
create: [
@@ -71,7 +76,8 @@ module.exports = {
7176

7277
after: {
7378
all: [
74-
populate({ schema: userSchema })
79+
populate({ schema: userSchema }),
80+
xss({ fields: xssFields })
7581
],
7682
find: [
7783
discard('content', 'user.coverImg', 'badgeIds')

0 commit comments

Comments
 (0)