2010-06-10 92 views
0

我不知道爲什麼,但TinyMCE的刪除textarea的問題TinyMCE的風格

所有

<style> 
... 
</style> 

信息我能做些什麼? 10x

回答

0

<style>標籤在文檔正文中無效。

有可能以某種方式保護它們(至少它在CKEDitor的繼任者中,請參閱here並搜索protectedSource),但主要問題應該是:他們爲什麼在那裏?

1

作爲記錄CKEditor不是TinyMCE的繼任者,只是競爭對手。

您可以通過在TinyMCE的驗證配置中將'style'指定爲允許的標籤之一來將樣式標籤保留在內容中。只需添加:

extended_valid_elements: "style" 

將您傳遞給init的配置。

0

如果您使用WYSIWYG TinyMCE或CKEditor和框架CodeIgniter版本> 2.0,則可能會遇到消除樣式屬性的問題。

您可以在提交表單後設置樣式。

這是地獄風格=「」?

也許你有這個選項在config.php文件中啓用:

$config['global_xss_filtering'] = TRUE; 

禁用全局過濾後,所見即所得不輸風格。

就個人而言,我並不想禁用此功能,所以我做了一個解決方法;基於Bart的建議,不亂用核心文件

編輯O);

此安全是爲某些加入鄰)原因,所以爲了不徹底擺脫它,我創建了一個存儲標籤樣式不會被刪除的地址的數組。

您需要創建MY_Security.php文件擴展名核安全 類,並添加修改功能_remove_evil_attributes。

protected function _remove_evil_attributes($str, $is_image){ 
    // All javascript event handlers (e.g. onload, onclick, onmouseover), style, and xmlns 
    $allowed = array("your allowed url's without domain like '/admin/edittext/'"); 
    if(in_array($_SERVER['REQUEST_URI'],$allowed)){ 
    $evil_attributes = array('on\w*', 'xmlns'); 
    }else{ 
    $evil_attributes = array('on\w*', 'style', 'xmlns'); 
    } 

    if ($is_image === TRUE){ 
    /* 
    * Adobe Photoshop puts XML metadata into JFIF images, 
    * including namespacing, so we have to allow this for images. 
    */ 
    unset($evil_attributes[array_search('xmlns', $evil_attributes)]); 
    } 

    do { 
    $str = preg_replace(
     "#&lt;(/?[^&gt;&lt;]+?)([^A-Za-z\-])(".implode('|', $evil_attributes).")(\s*=\s*)([\"][^&gt;]*?[\"]|[\'][^&gt;]*?[\']|[^&gt;]*?)([\s&gt;&lt;])([&gt;&lt;]*)#i", 
     "&lt;$1$6", 
     $str, -1, $count 
    ); 
    } while ($count); 
    return $str; 
} 

源:http://blog.codebusters.pl/en/codeigniter-202-tinymce-or-ckeditor-style-attribute-lost-after-update/#comment-543