gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 05:33:34 26 4
gpt4 key购买 nike

我正在使用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/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com