diff --git a/src/static/js/chat.js b/src/static/js/chat.js index c6b00af1..42800a83 100755 --- a/src/static/js/chat.js +++ b/src/static/js/chat.js @@ -164,15 +164,22 @@ exports.chat = (() => { // Call chat message hook hooks.aCallAll('chatNewMessage', ctx, () => { const cls = authorClass(ctx.author); - const html = - `
` + - `${padutils.escapeHtml(ctx.authorName)}:` + - // ctx.text was HTML-escaped before calling the hook, and ctx.timeStr couldn't have had - // any HTML. Hook functions are trusted to not introduce an XSS vulnerability by adding - // unescaped user input to either ctx.text or ctx.timeStr. - `${ctx.timeStr} ${ctx.text}
`; - if (isHistoryAdd) $(html).insertAfter('#chatloadmessagesbutton'); - else $('#chattext').append(html); + const chatMsg = $('')
+ .attr('data-authorId', ctx.author)
+ .addClass(cls)
+ .append($('').text(`${ctx.authorName}:`))
+ .append($('')
+ .addClass('time')
+ .addClass(cls)
+ // Hook functions are trusted to not introduce an XSS vulnerability by adding
+ // unescaped user input to ctx.timeStr.
+ .html(ctx.timeStr))
+ .append(' ')
+ // ctx.text was HTML-escaped before calling the hook. Hook functions are trusted to not
+ // introduce an XSS vulnerability by adding unescaped user input.
+ .append($('