如何在Symfony2 config.yml中配置HTML.SafeIframe和URI.SafeIframeRegexp?
我试过了:
exercise_html_purifier:
default:
Cache.SerializerPath: '% kernel.cache_dir% / htmlpurifier'
custom:
Cache.SerializerPath: '% kernel.cache_dir% / htmlpurifier'
Core.Encoding: 'utf-8'
URI.AllowedSchemes: {http: true}
HTML.SafeIframe: true
URI.SafeIframeRegexp: '% ^ (https:) // (www \ .youtube (- nocookie) \ com / embed / | player \ .vimeo \ .com / video /)%'
但它在URI.SafeIframeRegexp上给出了一个错误:
ParameterNotFoundException:您已经请求了一个不存在的参数" ^(https :) //(www \ .youtube( - nocookie)\ com / embed / | player \ .vimeo \ .com / video /? )? "
我试试这个:
URI.SafeIframeRegexp: "/^(https?:)?//(www.youtube(?:-nocookie)?.com/embed/|player.vimeo.com/video/)/"
和此:
URI.SafeIframeRegexp: "^(https?:)?//(www.youtube(?:-nocookie)?.com/embed/|player.vimeo.com/video/)"
和此:
URI.SafeIframeRegexp: "#^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)#"
没有更多错误,但仍然有效。在我的文中,我有:
<iframe width = "560" height = "315" src = "// www.youtube.com/embed/jAHlQ77lm10" frameborder = "0" allowfullscreen> </ iframe>
编辑2:我有:
HTML.SafeObject: true
Output.FlashCompat: true
但仍然无效。
编辑3: 我试过HTML.Allowed:iframe但是即使这样也行不通,因为我的其他标签不起作用。
我的上次配置:
# HTMLPurifier
exercise_html_purifier:
default:
Cache.SerializerPath: '%kernel.cache_dir%/htmlpurifier'
custom:
Cache.SerializerPath: '%kernel.cache_dir%/htmlpurifier'
Core.Encoding: 'utf-8'
URI.AllowedSchemes: { http: true }
HTML.SafeObject: true
Output.FlashCompat: true
HTML.SafeIframe: true
URI.SafeIframeRegexp: "#^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)#"
(我也在这里发布了这个问题:https://github.com/Exercise/HTMLPurifierBundle/issues/20)
虽然我希望视频出现。
答案 0 :(得分:0)
问题解决了。我的错误是将代码放入iframe:
<iframe width = "560" height = "315" src = "// www.youtube.com/embed/jAHlQ77lm10" frameborder = "0" allowfullscreen> </ iframe>
在我的textarea中,所以我不得不把它放在tinymce的VIEWCODE中。 非常愚蠢的错误。