Ajax Response Return Html Response (xss Veracode)
function viewAcc() { var errorMsg = ''; var result = true; $('.errorView').hide(); var accNum = document.getElementById('custAccNum').value; var accType = docum
Solution 1:
You can simply use .text()
instead of .html()
. If you don't have any markup coming from the server, then this is a perfectly viable alternative, since .text()
will prevent the content being interpreted as HTML
//doing sc+ript is only needed here because Stack Snippets otherwise throws an error.var msg = "This is <b>a message</b> with <script>console.log('some code')</sc"+"ript>";
$("#msgHtml").html(msg);
$("#msgText").text(msg);
<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><h3>Message via .html():</h3><divid="msgHtml"></div><h3>Message via .text():</h3><divid="msgText"></div>
Post a Comment for "Ajax Response Return Html Response (xss Veracode)"