I store html data in a database.
The html data is very simple, and is generated by a wysiwyg editor.
Before I store the html data in the database and I run it through HTMLPurifier, to remove any badness.
When I output data back out to the browser, because it is html data, obviously I cannot use php's htmlspecialchars().
I am wondering if there are any problems with this as far as XSS attacks are concerned. Is passing the data through HTMLPurifier before saving in the database enough? Are there any things I am missing / other steps I should be taking?
Thanks (in advance) for your help.
I've never had an issue with mainstream richtext editors.
XSS happen when people are able to embed raw html into your page using web forms, the input of which you output at a later date (so always encode user input when writing to screen).
This can't happen with a (good) text editor. If a user types in html code (e.g. < or >), the text editor will encode it anyway. The only tags it will create are its own.