Is obtaining the value of a
input with the jQuery function
<html> <textarea id="t1"></textarea> <script> var toBeDisplayed = $('#t1').val(); $('#elem').html(toBeDisplayed); </script> </html>
As Gumbo mentioned in his comment, it does not matter what you read in, but it does matter what you display after the fact. To simply answer your question, no. jQuery's
.val() does not have any filtering that will protect you from XSS. You could perhaps take in the value into
var toBeDisplayed and then perform your own filtering before it gets relayed to be displayed again.
Of course it is always safest to do the sanitizing on the server side before displaying the input back to the user. It can be done more quickly and easily in the browser, but any code running in the browser should not be considered entirety trusted; it could be modified or disabled.