I store unsanitized user input in my database, then escape it on output.
If I enter "><svg/onload=alert(3)>
into an input and save it in the database, then load a page that escapes the data, putting it back into the input, the page source shows:
... value=""><svg/onload=alert(3)>" ...
As you can see, it's escaped.
However, If I then run this code:
$(".somediv").html($("#myinput").val());
Then the following is put into the element:
""><svg/onload=alert(3)>"
And the alert box pops up.
What am I doing wrong here? I thought escaping my data on output was all I needed to do, but apparently when manipulating the DOM with jQuery that's not true.