yiisoft/yii2 — pull request #4656 by Alex-Code (2014-08-08 14:28:17+00:00)
Title: Update BaseHtmlPurifier.php

I needed an HTML5 data attribute to pass through purifying.
Using the ```HTML.AllowedAttributes``` wouldn't work as it clears the default whitelist.

I tried doing
```
$config = HTMLPurifier_Config::createDefault();
$def = $config->getHTMLDefinition(true);
$def->addAttribute('img', 'data-type', 'Text');

HtmlPurifier::process($content, $config);
```
but calling ```getHTMLDefinition``` finalizes the config which causes an error with this line.
```$purifier->config->set('Cache.SerializerPath', \Yii::$app->getRuntimePath());```

Using ```$config``` as a callable you can now do
```
HtmlPurifier::process($content, function($config) {
$def = $config->getHTMLDefinition(true);
$def->addAttribute('img', 'data-type', 'Text');
})
```