CKEditor自动删除样式属性并添加xss属性“已删除" [英] CKEditor automatically removes style attribute and add xss attribute 'Removed'

查看:70
本文介绍了CKEditor自动删除样式属性并添加xss属性“已删除"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CKEditor会自动删除样式属性并删除"添加xss属性,就像我将样式属性放在元素中一样:

CKEditor automatically removes style attribute and add xss attribute 'removed' like if I put a style attribute in a element:

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

保存后,我得到以下输出:

After save I got the following output:

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

推荐答案

我正在 CodeIgniter

使用$ this-> input-> post('filed_name',FALSE)的第二个参数进行工作

It's worked using 2nd argument of $this->input->post('filed_name', FALSE)

输入文字

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

这篇关于CKEditor自动删除样式属性并添加xss属性“已删除"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆