I'm a little bit over my head trying to configure HTML purifier for my needs.

I asked this question in stackoverflow and it seems that I might need to do something like this:

$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.DefinitionID', 'trusted');

if ($def = $config->maybeGetRawHTMLDefinition())
    $def->addAttribute('a', 'href', 'Text');

$purifier = new HTMLPurifier($config);

From what I gather, this means that I need to "add an attribute to the HTML Purifier definition".

So, my question is: Is there a way to do this with the .json purifier config file? Or should I try a custom plugin as described here?

I've never built a plugin, so obviously I would prefer the former. In any case, I would appreciate any pointers! Thanks in advance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.