Skip to content

Commit

Permalink
Prevent html injection using user tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchdev committed Apr 11, 2024
1 parent 7d481a0 commit 5a4938e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions assets/chat/js/messages/ChatUserMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ export default class ChatUserMessage extends ChatMessage {
else if (this.slashme || this.continued) ctrl = '';

const colorFlair = usernameColorFlair(chat.flairs, this.user);
const user = `${this.buildFeatures(this.user, chat)} <a title="${
this.title
}" class="${['user', colorFlair?.name].filter(Boolean).join(' ')}">${
this.user.displayName
}</a>`;
const user = `${this.buildFeatures(this.user, chat)} <a title="${this.title
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')}" class="${['user', colorFlair?.name]
.filter(Boolean)
.join(' ')}">${this.user.displayName}</a>`;
return this.wrap(
`${this.buildTime()} ${user}<span class="ctrl">${ctrl}</span> ${this.buildMessageTxt(
chat,
Expand Down

0 comments on commit 5a4938e

Please sign in to comment.