Dan*_*mes 0 htmlpurifier laravel-4
似乎即使在添加Config params以启用YouTube和Vimeo Iframe之后,我仍然会收到异常错误."不支持元素'iframe'[..]"
return array(
'encoding' => 'UTF-8',
'finalize' => true,
'preload' => false,
'settings' => array(
'default' => array(
'HTML.Doctype' => 'XHTML 1.0 Strict',
'HTML.Allowed' => 'blockquote,div,b,strong,i,em,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]',
'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
"HTML.SafeIframe" => 'true',
"URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/|api.soundcloud.com/tracks/)%",
'AutoFormat.AutoParagraph' => true,
'AutoFormat.RemoveEmpty' => true,
),
),
Run Code Online (Sandbox Code Playgroud)
您的问题是您使用的是Doctype XHTML 1.0 Strict.在HTML.SafeIframe的文档中,声明:
是否在不受信任的文档中允许iframe标记.此指令必须附带允许的iframe白名单,例如%URI.SafeIframeRegexp,否则会导致致命错误.该指令对严格的doctypes没有影响,因为iframe无效.
所以你应该使用Transitional.以下配置将正常工作:
return array(
'encoding' => 'UTF-8',
'finalize' => true,
'preload' => false,
'settings' => array(
'default' => array(
'HTML.Doctype' => 'XHTML 1.0 Transitional',
'HTML.Allowed' => 'iframe[src|width|height|class|frameborder],blockquote,div,b,strong,i,em,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]',
'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
"HTML.SafeIframe" => true,
"URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/|api.soundcloud.com/tracks/)%",
'AutoFormat.AutoParagraph' => true,
'AutoFormat.RemoveEmpty' => true,
),
),
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
554 次 |
| 最近记录: |