i'm using a jQuery ajax call to set the value of a textarea.
If I use php's htmlentities() and then use jquerys $(textarea).val() it doesn't display the characters but the entities.
Without htmlentities() everything looks fine. No XSS while using val() but off course vulnerable if the script is accessed without jquery.
What happens?
.load() works but I can't use it. load() just breaks after I use the BBcodefunctions ( DOM does not update the textarea, in Firebug everything looks like it should)
After using val(), html() breaks.
Why?
Jquery code:
$.ajax({
type: 'GET',
encoding:"UTF-8",
dataType:"html",
contentType: "text/plain;
charset=UTF-8",
url: "/quote.php?id=1",
context: document.body
}).done(function(data) { $('textarea').val(data); });
PHP code:
htmlentities($nonEncodedRawText, ENT_QUOTES, 'UTF-8')
Result in textbox:
</textarea><script type="text/javascript">
Result on direct access:
</textarea><script type="text/javascript">