Exercise/HTMLPurifierBundle

how to add custom attribute to whitelist by edit config.yml

jamesBan opened this issue ยท 4 comments

I use this bundle in my project, i want to konw how to setting config.yml.
this is the raw HTMLPurifier code.

<?php
$dirty_html = <<<EOF
<img src="/my.jpg" data-type="5" alt="" data-image-size="100,200" />
EOF;

$config = HTMLPurifier_Config::createDefault();
$def = $config->getHTMLDefinition(true);
$def->addAttribute('img', 'data-type', 'Text');
$def->addAttribute('img', 'data-image-size', 'Text');
$purifier = new HTMLPurifier($config);

I would like to do the same. Has anyone found out how to do it?

Still trying to find/understand this feature if anyone has a solution or a newer bundle that does the trick. :)

See https://github.com/heahprod/HTMLPurifierBundle/pull/2 that will hopefully be merged in #46.

Feel free to test the branch, I've tested it in a project of mine and it worked pretty well so far. It would be nice if you could report any issue. Thanks!

#52 has been merged and 3.0 is out as beta. Closing here, please open an issue if there is any bug with this feature (see the updated README and CHANGELOG files).