Skip to content

Commit

Permalink
add safestring to chatlog playerstats bestcps and bestfinishes
Browse files Browse the repository at this point in the history
  • Loading branch information
lythx committed Aug 27, 2024
1 parent 2723607 commit 2c3884d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugins/ui/dynamic_components/Chatlog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class ChatLog extends PopupWindow<{ page: number }> {
return centeredText(tm.utils.formatDate(messages[index + i].date, true), w, h)
}
const nicknameCell: GridCellFunction = (i, j, w, h) => {
return centeredText(tm.utils.safeString(tm.utils.strip(messages[index + i].nickname, false)), w, h)
return centeredText(tm.utils.safeString(tm.utils.safeString(tm.utils.strip(messages[index + i].nickname, false))), w, h)
}
const loginCell: GridCellFunction = (i, j, w, h) => {
const playerLogin = messages[index + i].login
Expand Down
2 changes: 1 addition & 1 deletion plugins/ui/dynamic_components/PlayerStats.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class PlayerStatsWindow extends PopupWindow {
if (params === undefined) { return '' }
const data: string[] = [
params.player.login,
tm.utils.strip(params.player.nickname, false),
tm.utils.safeString(tm.utils.strip(params.player.nickname, false)),
`${params.player.country} / ${params.player.countryCode}`,
titles.privileges[params.player.privilege as keyof typeof titles.privileges],
(stats.averages.list.findIndex(a => a.login === params.player.login) + 1).toString(),
Expand Down
6 changes: 5 additions & 1 deletion plugins/ui/static_components/race/BestCps.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ export default class BestCps extends StaticComponent {

const nicknameCell = (i: number, j: number, w: number, h: number): string => {
const bg = `<quad posn="0 0 1" sizen="${w} ${h}" bgcolor="${config.background}"/>`
return this.bestCps[i + cpIndex] === undefined ? '' : bg + (this.bestCps[i + cpIndex] === undefined ? '' : leftAlignedText(tm.utils.strip(this.bestCps[i + cpIndex].nickname, false), w, h, { textScale: config.textScale, padding: config.textPadding }))
return this.bestCps[i + cpIndex] === undefined ? '' :
bg + (this.bestCps[i + cpIndex] === undefined ? '' :
leftAlignedText(tm.utils.safeString(tm.utils.strip(
this.bestCps[i + cpIndex].nickname, false)), w, h,
{ textScale: config.textScale, padding: config.textPadding }))
}

const cpsToDisplay: number = this.cpAmount - cpIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default class BestFinishes extends StaticComponent {
const nicknameCell = (i: number, j: number, w: number, h: number): string => {
const bg = `<quad posn="0 0 1" sizen="${w} ${h}" bgcolor="${config.background}"/>`
return this.bestFinishes[i] === undefined ? '' : bg +
(leftAlignedText(tm.utils.strip(this.bestFinishes[i].nickname, false), w, h,
(leftAlignedText(tm.utils.safeString(tm.utils.strip(this.bestFinishes[i].nickname, false)), w, h,
{ textScale: config.textScale, padding: config.textPadding }))
}

Expand Down

0 comments on commit 2c3884d

Please sign in to comment.