Weeding out a few issues with my site when I found this curious issue.
<img src=".." width="1200" height="1200" alt="<script>alert("foo");</script>" />
The CMS appears to have done it's jobs and converted <script>alert('foo')</script> into what you see above. I display the caption with the following code.
site.caption = {
container : $('#caption'),
set : function(str) {
if (str && str.length) {
this.container.html('<span>'+str+'</span>').show(); console.log(str);
} else {
this.container.hide();
}
}
};
The function is called like this.
site.caption.set($(nextSlideElement).find('img').attr('alt'));
When this line runs an alert box pop's up with the text 'foo'. When I do the following in the site.caption.set function it shows the valid html.
console.log(str);
I am using jQuery 1.8.3. Does anyone know why this is happening? How do I show the text <script>alert('foo')</script> without it being run?