File tree Expand file tree Collapse file tree 4 files changed +1522
-11839
lines changed
apps/anonymous-message-board Expand file tree Collapse file tree 4 files changed +1522
-11839
lines changed Original file line number Diff line number Diff line change 1
1
const MongoClient = require ( "mongodb" ) . MongoClient ;
2
2
const ObjectId = require ( "mongodb" ) . ObjectID ;
3
3
const CONNECTION_STRING = process . env . DB_URI ;
4
+ const sanitizeHtml = require ( "sanitize-html" ) ;
4
5
5
6
function ReplyHandler ( ) {
6
7
this . replyList = function ( req , res ) {
@@ -35,7 +36,7 @@ function ReplyHandler() {
35
36
const now = new Date ( ) ;
36
37
const reply = {
37
38
_id : new ObjectId ( ) ,
38
- text : req . body . text ,
39
+ text : sanitizeHtml ( req . body . text ) ,
39
40
created_on : now ,
40
41
reported : false ,
41
42
delete_password : req . body . delete_password ,
@@ -52,7 +53,7 @@ function ReplyHandler() {
52
53
$set : { bumped_on : now } ,
53
54
$push : { replies : reply } ,
54
55
} ,
55
- ( ) => { }
56
+ ( ) => { }
56
57
) ;
57
58
}
58
59
) ;
@@ -73,7 +74,7 @@ function ReplyHandler() {
73
74
"replies._id" : new ObjectId ( req . body . reply_id ) ,
74
75
} ,
75
76
{ $set : { "replies.$.reported" : true } } ,
76
- ( ) => { }
77
+ ( ) => { }
77
78
) ;
78
79
}
79
80
) ;
Original file line number Diff line number Diff line change 1
1
const MongoClient = require ( "mongodb" ) . MongoClient ;
2
2
const ObjectId = require ( "mongodb" ) . ObjectID ;
3
3
const CONNECTION_STRING = process . env . DB_URI ;
4
+ const sanitizeHtml = require ( "sanitize-html" ) ;
4
5
5
6
function ThreadHandler ( ) {
6
7
this . threadList = function ( req , res ) {
@@ -41,7 +42,7 @@ function ThreadHandler() {
41
42
this . newThread = function ( req , res ) {
42
43
const board = req . params . board ;
43
44
const thread = {
44
- text : req . body . text ,
45
+ text : sanitizeHtml ( req . body . text ) ,
45
46
created_on : new Date ( ) ,
46
47
bumped_on : new Date ( ) ,
47
48
reported : false ,
@@ -73,7 +74,7 @@ function ThreadHandler() {
73
74
collection . findOneAndUpdate (
74
75
{ _id : new ObjectId ( req . body . report_id ) } ,
75
76
{ $set : { reported : true } } ,
76
- ( ) => { }
77
+ ( ) => { }
77
78
) ;
78
79
}
79
80
) ;
Original file line number Diff line number Diff line change 16
16
"express" : " 4.18.2" ,
17
17
"helmet" : " 3.23.3" ,
18
18
"mocha" : " 9.2.2" ,
19
- "mongodb" : " 3.7.3"
19
+ "mongodb" : " 3.7.3" ,
20
+ "sanitize-html" : " ^2.8.1"
20
21
},
21
22
"license" : " MIT"
22
23
}
You can’t perform that action at this time.
0 commit comments