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

170
Views
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
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!