Search code examples
phpjavascriptcodeigniterwysiwygjwysiwyg

WYSIWYG editor security question (preventing malicious input)


I'm using jWYSIWYG in a form I'm creating that posts to a database and was wondering how you can prevent a malicious user from trying to inject code in the frame?

Doesn't the editor need brackets (which I'd normally strip during the post process) in order to display styles?


Solution

  • I have encountered similar situations, and I have started using HTMLPurifier on my PHP backend which will prevent every attack vector I can think of. It is easy to install, and will allow you to whitelist the elements and attributes. It also prevents the XSS attacks that could still exist whilst using htmlentities.