Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba


Go to End

2 Posts   1001 Views


Community Member, 46 Posts

24 January 2013 at 6:56pm

After upgrading to SS3 I am running into problems with loading of HTMLPurifier which I use to clean frontend TinyMCE text entries. I get the following error message:

[User Error] Uncaught Exception: HTML Purifier autoloader registrar is not compatible with non-static object methods due to PHP Bug #44144; Please do not use HTMLPurifier.autoload.php (or any file that includes this file); instead, place the code: spl_autoload_register(array('HTMLPurifier_Bootstrap', 'autoload')) after your own autoloaders.

Where would I put that code? I saw that the spl_autoload_register function gets called in the manifest ClassLoader class, but I don't know how to add the other autoloader to that.

Can anybody help me with this?



Community Member, 46 Posts

25 January 2013 at 2:05pm

Edited: 25/01/2013 2:06pm

The answer to this is easy actually, you can avoid the whole autoloader thing if you just get the standalone version. I was just too tired yesterday..

As there's not much documentation on this topic in general, I though I'd just post my way of implementing HTMLPurifier. Perhaps somebody has a better way.

I just dropped in HTMLpurifier.standalone.php under mysite/thirdparty/ (it could be anywhere really), then created a class Purifier.php:

class Purifier

//put your code here

public static function purify($content)

$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'span,p,br,a,h1,h2,h3,h4,h5,strong,em,u,ul,li,ol,hr,blockquote,sub,sup,p[class],img');
$config->set('HTML.AllowedElements', array('span','p','br','a','h1','h2','h3','h4','h5','strong','em','u','ul','li','ol','hr','blockquote','sub','sup','img'));
$config->set('HTML.AllowedAttributes', 'style,target,title,href,class,src,border,alt,width,height,title,name,id,align,valign');
$config->set('CSS.AllowedProperties', 'text-align,font-weight,text-decoration');
$config->set('AutoFormat.RemoveEmpty', true);
$config->set('Attr.ForbiddenClasses', array('MsoNormal'));

$purifier = new HTMLPurifier($config);
return $cleanCode = $purifier->purify($content);

No you can call Purifier::purify($content) from anywhere.

I also tried the class in the CMS and that worked as well:
$purifier = HTMLCleaner::inst();
$cleanhtml = $purifier->cleanHTML($content);
But this is without the config then.