0

サイトに nicedit (http://nicedit.com/) を使用することを検討しています。

nicedit は単純にボタンを使用して単純な html を作成し、ユーザーが保存するとその html が送信されると想定しています。

  1. おすすめですか?誰かがまだそれに取り組んでいますか?
  2. 後でこの HTML を自分のサイトのどこかに表示すると仮定すると、ユーザーが悪意のある JavaScript を植えることができて危険ではないでしょうか? そうでない場合、nicedit はどのようにこれを防止しますか?
  3. また、後でこの HTML を表示するとき、私の css の影響を受けますか? もしそうなら、どうすればこれを防ぐことができますか?

ありがとう。

4

2 に答える 2

0

これは私が使用するもので、データベースにチャッキングする前にniceditインスタンスのコンテンツを一掃するための魅力のように機能します

function cleanFromEditor($text) { 

    //try to decode html before we clean it then we submit to database
    $text = stripslashes(html_entity_decode($text));

    //clean out tags that we don't want in the text
    $text = strip_tags($text,'<p><div><strong><em><ul><ol><li><u><blockquote><br><sub><img><a><h1><h2><h3><span><b>');

    //conversion elements
    $conversion = array(
        '<br>'=>'<br />',
        '<b>'=>'<strong>',
        '</b>'=>'</strong>',
        '<i>'=>'<em>',
        '</i>'=>'</em>'
    );

    //clean up the old html with new
    foreach($conversion as $old=>$new){
        $text = str_replace($old, $new, $text);
    }   

    return htmlentities(mysql_real_escape_string($text));
} 
于 2011-12-31T05:53:56.680 に答える