Welcome! » Log In » Create A New Profile

Detect if HTML Purifier in include path?

Posted by FunkyRes 
Detect if HTML Purifier in include path?
June 27, 2009 08:44AM

I'm developing a web app for distribution. I'd like HTML Purifier to be an optional addition but not a requirement (I do extensive output filtering via a DOMDocument based filter I wrote that enforces most of mozilla's CSP server side), but basically use it if it's available on the system and in the include path.

What's the best way to detect it's presence?

If it is present on the system, I'll need to configure it - ala

if (testForPurifierAvailabilty) {
$pconfig = HTMLPurifier_Config::createDefault();
$pconfig->set('HTML','Doctype','XHTML 1.1');

$purifier = new HTMLPurifier($pconfig);
$output = $purifier->purify($output);

Are there any version specific considerations I need to worry about? IE earlier versions that don't work with the above syntax that I need to try to detect?

Re: Detect if HTML Purifier in include path?
June 27, 2009 03:23PM

You could try including it with the shutup operator (@), and then test if the appropriate class got defined. My take on the matter is a user should explicitly include it in some config file, and you shouldn't include in your code/.

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