I am trying to display comments on a page and have some problems.
There are two different types of comments I'm trying to process:
(1) Type XSS. <script type="text/javascript">alert('hi')</script>. This is pretty easy, avoiding it before it enters the database and then running stripslashes and htmlentities on it.
(2) It breaks the comment with <br>. When the data is stored in the database, I run nl2br, so the data looks like hi<br>hello<br><br>etc. However, when I show this comment, <br>they do not turn into page breaks as I want them.
Any idea what to do? I should note that disabling htmlentities captures the second type, but the first type runs as pure html and displays a warning dialog.
Thanks Phil
source
share