flash - 如何强制TinyMCE使用YouTube嵌入式Flash代替iframe?

标签 flash iframe youtube tinymce

我正在使用TinyMCE 3.4.9,并试图强制媒体插件始终使用Flash嵌入而不是iFrame嵌入。

出于安全原因,我不想允许嵌入任何iFrame。

我已经手动设置了网址格式,以获取Flash嵌入对象而不是iFrame对象。

IE-

  • Flash嵌入:http://www.youtube.com/v/fWNaR-rxAic
  • iFrame嵌入:
    http://www.youtube.com/watch?v=fWNaR-rxAic

  • 是否可以执行以下两种操作之一:
  • 更改嵌入文件/ URL字段时,请修改URL,以便默认情况下将嵌入Flash对象。 (http://www.youtube.com/watch?v=fWNaR-rxAic将转换为http://www.youtube.com/v/fWNaR-rxAic)
  • 将调用更改为youtube,以便youtube将返回Flash对象而不是iFrame。

  • 我的TinyMCE初始化代码是:
    <script language="javascript" type="text/javascript">
        tinyMCE.init(
            {
                paste_remove_styles : true,
                gecko_spellcheck : true,
                theme_advanced_font_sizes : "1,2,3,4,5",
                extended_valid_elements:"script[charset|defer|language|src|type]",
                theme : "advanced",
                mode: "exact",
                plugins: "inlinepopups,emotions,searchreplace,paste,media",
                elements : "blogcontent",
                theme_advanced_toolbar_location : "top",
                theme_advanced_toolbar_align : "left",
                theme_advanced_buttons1 : "bold,italic,underline,strikethrough,sub,sup,|,fontselect,fontsizeselect,forecolor,|,link,unlink,|,backcolor",
                theme_advanced_buttons2 : "justifyleft,justifycenter,justifyright,|,search,replace,|,image,charmap,emotions, media,|,undo,redo",
                theme_advanced_buttons3 : "",
                theme_advanced_resize_horizontal : false,
                theme_advanced_resizing : false,
                file_browser_callback : 'file_browser',
                relative_urls : false,
                remove_script_host : false,
                paste_retain_style_properties : "font-size,color,font-family,background-color",
                setup : 
                    function(ed)
                    {
                        ed.onKeyUp.add(
                            function(ed, e)
                            {
                                ed.nodeChanged();
                            }
                        );
                    }
            }
        );
    
    </script>
    

    谢谢,

    最佳答案

    由于我还没有找到强制Flash嵌入youtube视频的方法,因此我针对iframe安全问题创建了解决方法。

    我已将iframe添加到允许的标签列表中,并在保存后向用户显示内容,我对所有iframe应用了白名单过滤器,该过滤器会提取白名单中没有src的所有iframe。

    function filterIframeBySource($text, $allowed_sources)
    {
        // regex to retrieve just the iframes
        $regex      = '/<iframe[0-9a-zA-Z \.\/=>:\-"]*<\/iframe>/';
        $matches    = array();
        $reg_pos    = preg_match($regex, $text, $matches);
    
        // loop through each match and check the src for that iframe
        $src_expression = '/ src="http:\/\/('.str_replace('.', '\.', implode('|', $allowed_sources)).')[0-9a-zA-Z\/-]*" /';
        foreach($matches as $match)
        {
            $src_pos    = preg_match($src_expression, $match);
    
            if($src_pos !== false && $src_pos === 0)
                $text   = str_replace($match, '[Removed iFrame]', $text);
        }
        return $text;
    }
    

    希望这可以帮助。

    关于flash - 如何强制TinyMCE使用YouTube嵌入式Flash代替iframe?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11569937/

    相关文章:

    javascript - 在 iFrame 中设置元素值 - Chrome 扩展

    youtube - YouTube API V3注释线程不适用于访问 token

    javascript - 如何在 Flash AS3 中构建自定义 slider ?

    flash - 创建一个大型二维数组并将其填充到 AS3 中

    c++ - 使用 C++ 玩 swf 游戏

    java - 下载 Youtube 视频?

    php - 从 YouTube 视频中获取标题并用 HTML/CSS 编写

    flash - 可以返回两种类型的方法的 AS3 最佳实践

    javascript - 有没有办法隐藏 IFRAME src 页面中的元素?

    javascript - 更改同域 IFrame 中的字体系列