I noticed that it's possible to XSS my chat application. Any suggestions on how to prevent this?
I've tried:
text = escape(text);
and
text = encodeURIComponent(text);
But everything just looks weird and clumsy. I would like it that if I wrote
<b>test</b>
it would print out that exact string, and not the bold version of it. Thanks.
<div class="chat-room"></div>
b.innerHTML = '<a target="_blank" href="http://steamcommunity.com/profiles/'+steamid+'"><img src="'+avatar+'" class="avatarka"></a><div class="msg_block"><span style="cursor:pointer" class="from">'+name+'</span>: <br><span style="font-size:14px;" class="msg">'+text+'</span></div>';
$('.chat-room').append(b);
$('.chat-room').scrollTop(100000);
This got really messy, if you need more info, please ask, and Ill provide what ever I can. Thanks.