【发布时间】:2014-09-01 02:57:47
【问题描述】:
我在 Laravel 4.2 上使用 mewebstudio/Purifier 包服务提供商 HTMLPurifier。
由于某种原因,我无法使 youtube iframe 功能正常工作。我什至尝试了作者的示例,但没有成功。
这是我的 HTMLPurifier 捆绑配置:
return array(
'encoding' => 'UTF-8',
'finalize' => true,
'preload' => false,
'settings' => array(
'default' => array(
'HTML.Doctype' => 'XHTML 1.0 Strict',
'HTML.Allowed' => 'div[style],b,strong,i,em,a[href|title|style],ul,ol,li,p[style],br,span[style],
img[width|height|alt|src],h1[style],h2[style],h3[style],h4[style],h5[style],table[class|style|summary],tr,td[abbr],tbody,thead',
'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
'HTML.SafeObject' => true,
'Output.FlashCompat' => true,
'HTML.SafeIframe' => true,
'URI.SafeIframeRegexp' => '%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%',
'AutoFormat.AutoParagraph' => true,
'AutoFormat.RemoveEmpty' => true,
'HTML.Nofollow' => true,
'URI.Host' => 'domain.com',
),
),
);
这是我在路线上的测试:
Route::get('/clean', function() {
$pured = Purifier::clean('<iframe src="//www.youtube.com/embed/gLUdqi8J0mQ" width="640" height="360" frameborder="0"></iframe>', 'default');
return $pured;
});
其他一切都有效,但这个。
感谢各位勇士:)
【问题讨论】:
标签: php iframe youtube laravel-4 htmlpurifier