Welcome! » Log In » Create A New Profile

Possible to encode instead of strip invalid HTML?

Posted by jonathansnook 
Possible to encode instead of strip invalid HTML?
May 02, 2008 12:56PM

After searching the documentation, I couldn't find anything to confirm this but I was wondering if there was a way, via some convenient option, to have HTML Purifier to encode anything that is not allowed instead of stripping it. For example, if a user wishes to post a code snippet of JavaScript, I'd like to have the < and > automatically converted into < and >.

At the moment, I'm using a version of kses5 that I hacked up to accommodate this but it'd be nice to have an out-of-the-box solution that does this while maintaining valid HTML.

Thanks. :)

Re: Possible to encode instead of strip invalid HTML?
May 02, 2008 01:35PM

What you're looking for are the CDATA tags ( js here ). HTML Purifier does have a %Core.EscapeInvalidTags, but it's a not a very good implementation.

Sorry, you do not have permission to post/reply in this forum.