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

165
Views
XSS attack in JavaScript, how to unsanitize HTML

While taking the input from the form, i did sanitize the HTML code to prevent XSS attack. Eg -

<img src=X onerror=alert("XSS attack")>

The above input is converted to -

&lt;img src=X onerror=alert(&quot;XSS attack&quot;)&gt;

The same is sent to Database.

But while displaying it, i would like to preserve the original input given by user. So basically i would like to show as below in the form

<img src=X onerror=alert("XSS attack")>  

I tried to un-sanitize, it showed as expected but the attack happens. That is alert pop up come up "XSS attack" - pop up.

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!