HtmlPurifierBundle 如何配置 URI.SafeIframeRegexp in config.yml S


HtmlPurifierBundle How to configure URI.SafeIframeRegexp in config.yml Symfony2?

如何配置 HTML。SafeIframe 和 URI。SafeIframeRegexp in Symfony2 config.yml?

我试过了:

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/|播放器 '' .vimeo '' .com/视频/?).?'".

我试试这个:

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。允许: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)

虽然我希望视频出现。

问题解决了。我的错误是输入了iframe的代码:

<iframe width = "560" height = "315" src = "// www.youtube.com/embed/jAHlQ77lm10" frameborder = "0" allowfullscreen> </ iframe>

在我的文本区域中,所以我不得不将其放在 tinymce 的 VIEWCODE 中。非常愚蠢的错误。