2017-08-28 12 views
0

CKEditorバージョンは、自動的にスタイル属性を削除し、私は要素にスタイル属性を置くかのように「削除」XSS属性を追加するスタイル属性を削除し、「削除」XSSの属性を追加します。CKEditorバージョンは自動的に

<div class="text-center" style="text-align: center;">Test Heading</div> 

私が得た保存した後次の出力:

<div class="text-center" xss="removed">Test Heading</div> 

私の設定は次のとおりです。

var toolbar_custom=[ 
    { name: 'document', items: [ 'Source' ] }, 
    { name: 'editing', items: [ 'Scayt' ] }, 
    { name: 'basicstyles', items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] }, 
    { name: 'paragraph', items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] }, 
    { name: 'insert', items: [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe' ] }, 
    { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] }, 
    { name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ]} 

]; 

jQuery(function(){ 
     CKEDITOR.replace('template_editor_custom',{ 
      uiColor:'#2778a7', 
      toolbar:toolbar_custom, 
      autoParagraph:false, 
      enterMode:CKEDITOR.ENTER_DIV, 
      allowedContent:true, 
      extraAllowedContent:'*{*}' 
     }) 
    }); 

のHTML :

<textarea class="form-control textbox-style" id="template_editor_custom" name="page[content]" placeholder="Page content"><?php echo set_value('page[content]', $content); ?></textarea> 

答えて

-1

これはCKEditorの問題ではありません。
私はあなたがCodeIgniter 2.xを使用しており、「グローバルXSSフィルタリング」を有効にしていると思われます。あなたが設定ファイルでそれをオフにする必要があります。

$config['global_xss_filtering'] = FALSE; 

xss=removedはCodeIgniterのに使用される典型的な消毒方法です。

+0

いいえ、私はCIのV3を使用しています。 1.X、私はコア/ Security.phpファイルをオーバーライドすることで問題を解決し、スタイルの制限をリストから削除しました。グローバルxssフィルタリングをfalseに設定すると、サイトのセキュリティ全体が損なわれます。 –

0

core/Security.phpファイルを変更して私の問題を解決しました。 ただ_sanitize_naughty_html機能にアクセスして、これらの二つの静的配列からスタイルタグを削除します。

static $naughty_tags = array(
      'alert', 'prompt', 'confirm', 'applet', 'audio', 'basefont', 'base', 'behavior', 'bgsound', 
      'blink', 'body', 'embed', 'expression', 'form', 'frameset', 'frame', 'head', 'html', 'ilayer', 
      'iframe', 'input', 'button', 'select', 'isindex', 'layer', 'link', 'meta', 'keygen', 'object', 
      'plaintext', 'style', 'script', 'textarea', 'title', 'math', 'video', 'svg', 'xml', 'xss' 
     ); 

     static $evil_attributes = array(
      'on\w+', 'style', 'xmlns', 'formaction', 'form', 'xlink:href', 'FSCommand', 'seekSegmentTime' 
     ); 

私は自分のサイト全体のセキュリティを損なうことなく、この方法のような問題を解決しました。将来、CIバージョンをアップグレードする場合は、アップグレード後にSecurity.phpの_sanitize_naughty_html関数内でこれらの2つの配列を見つけて、これら2つのリストからスタイルタグを削除してください。

ありがとうございます。

1

私はそれはの$ this - の第二引数>入力 - >ポスト( 'filed_name'、FALSE)

入力テキスト

を使用して働いていますCodeIgniterの

CKEditorバージョンを使用しています

<div style="background-color:#eee; padding:15px"> <span style="font-size:16px;"> <u>Friendly Reminder</u> </span> </div> 

実施例1

<?php 
    echo html_escape($this->input->post('template_editor_custom')); 
?> 

出力

<div xss=removed> 
    <span xss=removed> <u>Friendly Reminder</u> </span> 
</div> 

例2

<?php 
    echo html_escape($this->input->post('template_editor_custom', FALSE)); 
?> 

出力

<div style="background-color:#eee; padding:15px"> 
    <span style="font-size:16px;"> <u>Friendly Reminder</u> </span> 
</div> 
関連する問題