Take the 2-minute tour ×

I am using HTMLPurifier for cleaning the post input but I'd like it to escape (html encode) all broken tags or suspicious symbols instead of removing them completely. I have searched through it's docs and this site but without any luck. Still hope that I have missed something.

Opening tag is the most irritating. If someone tries to post a formula or comparison, writes "param1<param2" and does not put space in between, the purifier gets it as a wrong tag opening and completely discards everything on the right side.

I am using htmlspecialchars inside [code] tags, but I want to allow some html outside and cannot encode everything.. That is why I'm filtering it with HTMLPurifier. Your advice would be appreciated.

share|improve this question

1 Answer 1

Try %Core.AggressivelyFixLt or using %Core.LexerImpl set to DirectLex. I don't know offhand if this will work, it may not.

A partial solution is to set %Core.EscapeInvalidTags; but it's a pretty imperfect fix, and it may mangle some text.

share|improve this answer
I was pleasantly surprised, that you were the one, answering my question :) your htmlpurifier does a great job, but unfortunately this config params do not solve my task. I came to the conclusion that I should not mix html and content this way and either use editor with preview/html switcher or stick to bbcodes and remove all html. –  Samurai Girl Feb 7 '12 at 19:09

Your Answer


