Hello,
I am using Express-validator for Validating user input in my project, and I am using the escape() function to prevent the user from trying to inject anything.
router.post(
"/new/post",
ensureAuthenticated,
[
check("newPost", "field must not be empty")
.not()
.isEmpty()
.trim()
.escape()
.exists({ checkFalsy: true })
],
(req, res) => { ...rest of code... };
my problem is I want to only escape these “<” and “>” but not the ’ and " and &. how do I do this?