Question

Today I installed Composer and installed HTMLPurifier, which replaced my old zipped download. This moved my version from 4.2 to 4.4

This code now no longer works:

$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'a[href|title],em,strong,b,i,s,p'); 
$config->set('AutoFormat.Linkify', true); 
$purifier = new HTMLPurifier($config);

$do = is_null($comment) ? $this->comment : $comment;
$clean = $purifier->purify($do);

debug($clean);

If I remove the composer autoload, and reference back to the old library, it works. This is on a string that includes http://www.google.com in it. But $clean is identical to $do

edit Apparently, downloading through composer, the HTMLPURIFIER_PREFIX constant wasn't being created, and it wasn't loading the *.ser file (even though it existed. This is defined in library/HTMLPurifier/Bootstrap.php, but that file isn't included anywhere (therefore not defining, therefore not working).

edit2 Looks like in my case it doesn't play nice with Composer. It didn't include the Bootstrap.php file at all. Had to manually call HTMLPurifier_Bootstrap::registerAutoload(); from my app, and it's working better. Nice work me. More info here

Was it helpful?

Solution

Turns out, as I said above, that the problem is related to Composer <-> HTMLPurifier interacting, and not properly loading the Bootstrap.php file correctly. Manually calling HTMLPurifier_Bootstrap::registerAutoload(); seems to have fixed it for now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top