Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

89
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda