2012-07-19 41 views
1

我正在使用TinyMCE 3.4.9,並試圖強制媒體插件始終使用Flash嵌入代替iFrame嵌入。如何強制TinyMCE使用flash嵌入代替iframe?

出於安全原因,我不想允許嵌入任何iFrames。

我已手動格式化URL以獲取Flash嵌入對象而不是iFrame對象。

IE-

有沒有辦法做到兩者之一:

  1. 的平變化嵌入文件/ URL字段,修改URL以便嵌入Flash對象默認。 (http://www.youtube.com/watch?v=fWNaR-rxAic將轉換爲http://www.youtube.com/v/fWNaR-rxAic
  2. 將調用更改爲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> 

感謝,

回答

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; 
} 

希望這會有所幫助。

相關問題