I have an old ASP.NET application that uses freetextbox WYSIWYG editor. But it saves a weird html (not particular format of html)into database.
<TABLE class=mceVisualAid border=0 width=560 align=center height=395>
<TBODY>
<TR align=center>
<TD class=mceVisualAid><SPAN>
<H1 style=COLOR: rgb(0,0,0) align=center><SPAN><SPAN><SPAN><STRONG><FONT size=3><STRONG><FONT size=3><STRONG><FONT size=2><STRONG><FONT size=3> Message</FONT></STRONG></FONT></STRONG></FONT></STRONG></FONT></STRONG></SPAN></SPAN></SPAN></H1>
<H1 style=COLOR: rgb(0,0,0) align=center><SPAN><SPAN><SPAN><STRONG><FONT size=3><STRONG><FONT size=3><STRONG><FONT size=2><STRONG><FONT size=3>16 August 2013</FONT>
Now I'm using ckeditor WYSIWYG in as ASP.net MVC application which uses same data that is saved in databse but i'm not getting a perfect way to render that html into editor. My config.js of ckeditor is :
CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
config.entities = false;
config.basicEntities = false;
config.entities_greek = false;
config.entities_latin = false;
};
Try using this in the View:
@Html.Raw(HttpUtility.HtmlDecode(Model.MyContent)).ToHtmlString();
Just verify the input in the CKEditor checks for XSS och illegal tags.
One way to do this is using a external anti-XSS library and before save to the database you should run it trough the sanitizer. The important thing is to do it on the Server-side.
Below is just a suggestion on a anti-XSS library (don't know if there is something better since i used this a long time ago)