<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Detect if HTML Purifier in include path?</title>
        <description>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) {
require_once('HTMLPurifier.auto.php');
$pconfig = HTMLPurifier_Config::createDefault();
$pconfig-&amp;gt;set('HTML','Allowed','div[class],p,br,strong,em,span[class],span[style],a[href],img[class],img[src],img[alt],ol,ul,li');
$pconfig-&amp;gt;set('HTML','Doctype','XHTML 1.1');

$purifier = new HTMLPurifier($pconfig);
$output = $purifier-&amp;gt;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?</description>
        <link>http://htmlpurifier.org/phorum/read.php?2,3756,3756#msg-3756</link>
        <lastBuildDate>Wed, 19 Jun 2013 14:59:59 -0400</lastBuildDate>
        <generator>Phorum 5.2.18</generator>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,3756,3760#msg-3760</guid>
            <title>Re: Detect if HTML Purifier in include path?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,3756,3760#msg-3760</link>
            <description><![CDATA[<p>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/.</p>]]></description>
            <dc:creator>Ambush Commander</dc:creator>
            <category>General</category>
            <pubDate>Sat, 27 Jun 2009 15:23:21 -0400</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,3756,3756#msg-3756</guid>
            <title>Detect if HTML Purifier in include path?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,3756,3756#msg-3756</link>
            <description><![CDATA[<p>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.</p>

<p>What's the best way to detect it's presence?</p>

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

<pre>
if (testForPurifierAvailabilty) {
require_once('HTMLPurifier.auto.php');
$pconfig = HTMLPurifier_Config::createDefault();
$pconfig-&gt;set('HTML','Allowed','div[class],p,br,strong,em,span[class],span[style],a[href],img[class],img[src],img[alt],ol,ul,li');
$pconfig-&gt;set('HTML','Doctype','XHTML 1.1');

$purifier = new HTMLPurifier($pconfig);
$output = $purifier-&gt;purify($output);
}
</pre>

<p>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?</p>]]></description>
            <dc:creator>FunkyRes</dc:creator>
            <category>General</category>
            <pubDate>Sat, 27 Jun 2009 08:44:06 -0400</pubDate>
        </item>
    </channel>
</rss>
