Pri*_*tha 2 html javascript php ckeditor
CKEditor 会自动删除样式属性并添加 xss 属性“已删除”,就像我在元素中放置样式属性一样:
<div class="text-center" style="text-align: center;">Test Heading</div>
Run Code Online (Sandbox Code Playgroud)
保存后我得到以下输出:
<div class="text-center" xss="removed">Test Heading</div>
Run Code Online (Sandbox Code Playgroud)
我的配置是:
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:'*{*}'
})
});
Run Code Online (Sandbox Code Playgroud)
网址:
<textarea class="form-control textbox-style" id="template_editor_custom" name="page[content]" placeholder="Page content"><?php echo set_value('page[content]', $content); ?></textarea>
Run Code Online (Sandbox Code Playgroud)
我在CodeIgniter 中使用CKEditor
它使用 $this->input->post('filed_name', FALSE) 的第二个参数起作用
输入文本
<div style="background-color:#eee; padding:15px">
<span style="font-size:16px;"> <u>Friendly Reminder</u> </span>
</div>
Run Code Online (Sandbox Code Playgroud)
示例 1
<?php
echo html_escape($this->input->post('template_editor_custom'));
?>
Run Code Online (Sandbox Code Playgroud)
输出
<div xss=removed>
<span xss=removed> <u>Friendly Reminder</u> </span>
</div>
Run Code Online (Sandbox Code Playgroud)
示例 2
<?php
echo html_escape($this->input->post('template_editor_custom', FALSE));
?>
Run Code Online (Sandbox Code Playgroud)
输出
<div style="background-color:#eee; padding:15px">
<span style="font-size:16px;"> <u>Friendly Reminder</u> </span>
</div>
Run Code Online (Sandbox Code Playgroud)