问题
I am using HTMLPurifier and this package for Laravel 5:
https://github.com/mewebstudio/Purifier
However, the docs show to use it like this:
$clean = Purifier::clean($dirty);
and the default config file is:
return [
'encoding' => 'UTF-8',
'finalize' => true,
'cachePath' => storage_path('app/purifier'),
'settings' => [
'default' => [
'HTML.Doctype' => 'XHTML 1.0 Strict',
'HTML.Allowed' => 'img[alt|src],ul,li,p,br,b',
'CSS.AllowedProperties' => '',
//'AutoFormat.AutoParagraph' => true,
'AutoFormat.RemoveEmpty' => true,
],
'test' => [
'Attr.EnableID' => true
],
"youtube" => [
"HTML.SafeIframe" => 'true',
"URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%",
],
],
];
This works fine, but I need to do some custom config work to allow the use of some HTML elements, namely the figure element tag.
In the docs for HTMLPurifier and elsewhere it shows doing this for example:
$def->addElement('figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common');
$def->addElement('figcaption', 'Inline', 'Flow', 'Common');
But no matter what I try I cannot use the Laravel config file to add new elements. Any help?
来源:https://stackoverflow.com/questions/37186005/laravel-mews-htmlpurifier-add-custom-config