Is jQuery's $ safe from XSS?

jquery, xss

Solution

No $ is not XSS safe.

You can inject arbitrary JavaScript using this trick.

$("<img src=x onerror=alert(/xss/.source)>")

Problem

In jQuery: ``` $('<script>alert("foo");</script>') // nothing shows up // wrap it in a <p> $('<script>alert("foo");</script>').wrap('<p>') // oh no, an alert just popped up. ``` Is `$('any string what so ever')` able to cause JavaScript to execute on any browser?

Original source