Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

88
Views
Un-Sanitizing / Un-Escaping Content Retrieved from Database

I'm experiencing an issue that is causing me more trouble than I would expect it to. I have created a blog site which involves taking a user's post and sanitizing the content that is sent. To sanitize the data I use express-validator's body.escape() method, and it is doing it's job. My issue is with the display of the data when it is retrieved and served on the webpage - the content is still escaped when it is displayed (i.e., instead of displaying an apostrophe, it displays "& #x27;". This seems like it would be a common problem with readily available solutions, but I can't seem to figure out how to easily unescape the content to deliver it to the user.

The function which displays the blog posts to the users is:

exports.index = function (req, res, next) {
Post.find({}, "title content date tags formatted_date")
.sort({ date: -1 })
.populate("tags")
.exec(function (err, list_posts) {
  if (err) {
    return next(err);
  }
  //Successful, so render
  res.render("index", {
    title: `Blog Site`,
    post_list: list_posts,
    user: req.user,
    home: true,
  });
});
};

Any guidance here would be highly appreciated. I would like to unescape list_posts.content.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!