在HTML Purifier中允许Youtube视频

时间:2012-03-05 11:16:07

标签: html xss htmlpurifier

我想允许两者<对象>和< iframe> HTLM净化器中的YouTube视频。我一直在寻找各地,包括文档,但找不到任何有效的解决方案。

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

您需要配置HTMLPurifier以允许您需要的标记。

// array of allowed tags
$tagsAllowed = array('object, iframe');

// for each tag, set it as allowed
foreach ($tagsAllowed as $tag)
{
    $config->set('HTML.Allowed', $tag);
}

// instantiate HTMLPurifier with the configuration
$purifier = new HTMLPurifier($config);

要接受标签中的某些参数,您必须将它们放在“[”和“]”之间,如:

a[href]

这接受来自a而不是任何其他的参数href。

相关问题