Answer the question
In order to leave comments, you need to log in
How to protect an input field that may contain html tags from XSS attacks?
I have a thematic portal where users can publish their material.
This material may contain HTML tags, so it cannot be output via the htmlspecialchars() function.
It would be possible to filter tags with strip_tags(), but that doesn't solve the problem.
How to filter the received data and remove attacks like this:
<body onload=alert('xss')>
<img src=javascript:alert('xss')>
<body background="javascript:alert('xss')" >
<meta http-equiv="refresh" content="0;url=javascript:alert('xss');">
<style type="text/javascript">alert('xss');</style>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question