gritter: Treat strings as text, not HTML

This forces users to use jQuery or DOM objects if they want
formatting, which helps avoid XSS vulnerabilities.
This commit is contained in:
Richard Hansen 2020-10-19 20:48:53 -04:00 committed by John McLear
parent 8463134125
commit a712ce457d
2 changed files with 9 additions and 4 deletions

View file

@ -193,7 +193,10 @@ var chat = (function()
if(!chatOpen && ctx.duration > 0) {
$.gritter.add({
text: '<span class="author-name">' + ctx.authorName + '</span>' + ctx.text,
// Note: ctx.authorName and ctx.text are already HTML-escaped.
text: $('<p>')
.append($('<span>').addClass('author-name').html(ctx.authorName))
.append(ctx.text),
sticky: ctx.sticky,
time: 5000,
position: 'bottom',