Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit navbar and comments #34

Merged
merged 5 commits into from
May 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add xss to comments routes
  • Loading branch information
dbajollari1 committed May 5, 2023
commit baec714cabebfdf2f3ceb4a5de2e07ceb815c182
13 changes: 11 additions & 2 deletions routes/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ router
if (commentInfo.replyingToID.toLowerCase() !== "null") {
commentInfo.replyingToID = helpers.checkId(commentInfo.replyingToID);
}
commentInfo.replyingToID = xss(commentInfo.replyingToID);
commentInfo.contentInput = xss( commentInfo.contentInput);
} catch (e) {
return res.status(400).json({error: e});
}
Expand All @@ -67,7 +69,6 @@ router

try {
const newComment = await commentData.create(req.params.ticketId, req.session.user._id, commentInfo.replyingToID, commentInfo.contentInput);
let redirectURL = '/tickets/view/' + req.params.ticketId;
return res.status(200).json(newComment);
} catch (e) {
res.status(500).json({error: e});
Expand Down Expand Up @@ -161,9 +162,17 @@ router
} catch (e) {
return res.status(404).json({error: e});
}
try{
if(!req.body.content) throw "Error: Must provide content in request body";
} catch (e) {
return res.status(400).json({error: e});
}

let content = req.body.content;
let content;
try {
if(!req.body.content) throw "Error: Must provide content in request body";
req.body.content = xss(req.body.content);
content = req.body.content;
content = helpers.checkString(content, "Content")
} catch (e) {
return res.status(400).json({error: e});
Expand Down