Laravel Mews HTMLPurifier - add custom config

最后都变了- 提交于 2019-12-11 11:07:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!