1

私は TinyMCE 3.4.9 を使用しており、メディア プラグインが常に iFrame 埋め込みではなく Flash 埋め込みを使用するように強制しようとしています。

セキュリティ上の理由から、iFrame の埋め込みを許可したくありません。

URL を手動でフォーマットして、iFrame オブジェクトの代わりに Flash 埋め込みオブジェクトを取得しました。

IE-

2つのうちの1つを行う方法はありますか:

  1. 埋め込みファイル/URL フィールドの変更時に、Flash オブジェクトがデフォルトで埋め込まれるように URL を変更します。(http://www.youtube.com/watch?v=fWNaR-rxAic は http://www.youtube.com/v/fWNaR-rxAic に変換されます)
  2. youtube への呼び出しを変更して、youtube が iFrame ではなく Flash オブジェクトを返すようにします。

私の 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>

ありがとう、

4

1 に答える 1

1

YouTubeビデオのフラッシュ埋め込みを強制する方法が見つからなかったため、iframeのセキュリティ問題の回避策を作成しました。

許可されたタグリストにiframeを追加し、保存後にユーザーにコンテンツを表示すると、ホワイトリストにsrcがないiframeを引き出すすべての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;
}

お役に立てれば。

于 2012-07-24T17:18:22.647 に答える