I have created a website based on
SQL Server 2014
C# (ASP.NET)
Javascript and jQuery
The user can store information within a textbox on my site. To prevent injection, I can use encode / decode from special character. The user should be able to submit code like below but the code should not executed. So far so good.
<script type="text/javascript">
$(document).ready(function () {
console.log('uuuuups.....');
});
</script>
This code will be stored as is to database. (without encoding first). Now I would like to offer a ckeditor to my users and give the ability to use the code-plugin. The code-plugin itself creates the following code:
<pre class="brush:jscript;">
<script type="text/javascript">
$(document).ready(function () {
console.log('uuuuups....');
});
</script></pre>
I have tried to replace charcter within SQL like
replace(replace(@text, '<', '<'), '>', '>')
But this seems to break the code when I try to view. My problem now is, how to handle this? Do I have encode twice? Every hint will be appreciated.