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

171
Visualizações
Can the same encoding be used for HTML attribute and content sanitization?

In my JS application, I have to protect against the first 2 rules mentioned in the OWASP Anti XSS cheatsheet:

Rule1:

<body>
...ENCODE UNTRUSTED DATA BEFORE PUTTING HERE...
</body>

Rule 2

<div attr="...ENCODE UNTRUSTED DATA BEFORE PUTTING HERE...">content

According to the guide, for rule 1, the following characters &'"<> should be encoded.

So if I have the following encoding function, this should be sufficent no?

 .replace(/&/g, '&amp;')
 .replace(/'/g, '&apos;')
 .replace(/"/g, '&quot;')
 .replace(/</g, '&lt;')
 .replace(/>/g, '&gt;')

Can I use this encoding to protect the app in these 2 cases (even though for rule 2, only the quotes should be sufficent right?)?

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