2013-10-04 144 views
2

我嘗試將HTML淨化器與Laravel(https://github.com/mewebstudio/Purifier)集成。HTMLPurifier與Laravel 4無法正常工作

做的文檔,這裏是配置文件purifier.php

return array(
"settings" => array(
    "HTML.Allowed" => "div,p[align|style],strong,a[href|title|mailto],em,table[class|width|cellpadding],td,tr,h3,h4,h5,hr,br,u,ul,ol,li,img[src|width|height|alt|class],span[class|style],strike,sup,sub,code", 
    "HTML.SafeIframe" => 'true', 
    "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%", 
), 

);

在這個配置中,我嘗試允許H3,H4,但它們總是被剝離。 我正在使用PHP 5.5.4

任何幫助將不勝感激。

回答

0

我找到答案我自己。我要加載的配置,並與淨化拋磚引玉吧::乾淨如下:

$purifier_config = Config::get('purifier.settings'); 
$content = Purifier::clean($content, $purifier_config); 
0

或者這似乎工作(REF https://github.com/mewebstudio/Purifier/blob/master/src/Mews/Purifier/Purifier.php#L81

return array(
    "default" => array(
     "settings" => array(
      "HTML.Allowed" => "div,p[align|style],strong,a[href|title|mailto],em,table[class|width|cellpadding],td,tr,h3,h4,h5,hr,br,u,ul,ol,li,img[src|width|height|alt|class],span[class|style],strike,sup,sub,code", 
      "HTML.SafeIframe" => 'true', 
      "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%", 
     ), 
    ), 
);