Skip to content

Commit

Permalink
added sanitization feature resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ng committed Sep 25, 2024
1 parent 67ced51 commit 4f5224c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/controllers/write/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ Topics.create = async (req, res) => {
Topics.reply = async (req, res) => {
const id = await lockPosting(req, '[[error:already-posting]]');
try {
<<<<<<< Updated upstream
<<<<<<< Updated upstream
=======
=======
>>>>>>> Stashed changes
console.log("Anonymous flag received in reply:", isAnonymous);

Check failure on line 36 in src/controllers/write/topics.js

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

Check failure on line 36 in src/controllers/write/topics.js

View workflow job for this annotation

GitHub Actions / test

'isAnonymous' was used before it was defined
const isAnonymous = req.body.anon;
let replyData = { ...req.body, tid: req.params.tid };

Check failure on line 38 in src/controllers/write/topics.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 2 tabs but found 8 spaces

Check failure on line 38 in src/controllers/write/topics.js

View workflow job for this annotation

GitHub Actions / test

'replyData' is never reassigned. Use 'const' instead

// Sanitize content to avoid XSS attacks
replyData.content = validator.escape(replyData.content);

Check failure on line 41 in src/controllers/write/topics.js

View workflow job for this annotation

GitHub Actions / test

'validator' is not defined

if (isAnonymous) {

Check failure on line 43 in src/controllers/write/topics.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 2 tabs but found 8 spaces
console.log("Post is anonymous. Modifying the username and userslug.");

Check failure on line 44 in src/controllers/write/topics.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 3 tabs but found 12 spaces

Check failure on line 44 in src/controllers/write/topics.js

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote
replyData.username = 'Anonymous User';
Expand All @@ -49,12 +48,11 @@ Topics.reply = async (req, res) => {
console.log("Post is not anonymous.");
}
console.log("Final reply data being sent:", replyData);
>>>>>>> Stashed changes
const payload = await api.topics.reply(req, { ...req.body, tid: req.params.tid });
helpers.formatApiResponse(200, res, payload);
} finally {
await db.deleteObjectField('locks', id);
}
}gi
};

async function lockPosting(req, error) {
Expand Down

0 comments on commit 4f5224c

Please sign in to comment.