Index: binaries/data/mods/public/gui/common/functions_utility.js =================================================================== --- binaries/data/mods/public/gui/common/functions_utility.js +++ binaries/data/mods/public/gui/common/functions_utility.js @@ -49,23 +49,14 @@ /** * Escape tag start and escape characters, so users cannot use special formatting. - * Also limit string length to 256 characters (not counting escape characters). */ -function escapeText(text, limitLength = true) +function escapeText(text) { - if (!text) - return text; - - if (limitLength) - text = text.substr(0, 255); - return text.replace(/\\/g, "\\\\").replace(/\[/g, "\\["); } function unescapeText(text) { - if (!text) - return text; return text.replace(/\\\\/g, "\\").replace(/\\\[/g, "\["); } Index: binaries/data/mods/public/gui/lobby/lobby.js =================================================================== --- binaries/data/mods/public/gui/lobby/lobby.js +++ binaries/data/mods/public/gui/lobby/lobby.js @@ -154,7 +154,7 @@ "join": msg => { addChatMessage({ "text": "/special " + sprintf(translate("%(nick)s has joined."), { - "nick": msg.text + "nick": escapeText(msg.text) }), "time": msg.time, "isSpecial": true @@ -163,7 +163,7 @@ "leave": msg => { addChatMessage({ "text": "/special " + sprintf(translate("%(nick)s has left."), { - "nick": msg.text + "nick": escapeText(msg.text) }), "time": msg.time, "isSpecial": true @@ -197,7 +197,7 @@ translate("%(nick)s is not a moderator anymore."); addChatMessage({ - "text": "/special " + sprintf(txt, { "nick": msg.text }), + "text": "/special " + sprintf(txt, { "nick": escapeText(msg.text) }), "time": msg.time, "isSpecial": true }); @@ -208,8 +208,8 @@ "nick": msg => { addChatMessage({ "text": "/special " + sprintf(translate("%(oldnick)s is now known as %(newnick)s."), { - "oldnick": msg.text, - "newnick": msg.data + "oldnick": escapeText(msg.text), + "newnick": escapeText(msg.data) }), "time": msg.time, "isSpecial": true @@ -487,13 +487,13 @@ if (reason) reason = sprintf(translateWithContext("lobby kick", "Reason: %(reason)s"), { - "reason": reason + "reason": escapeText(reason) }); if (nick != g_Username) { addChatMessage({ - "text": "/special " + sprintf(kickString, { "nick": nick }) + " " + reason, + "text": "/special " + sprintf(kickString, { "nick": escapeText(nick) }) + " " + reason, "time": time, "isSpecial": true }); @@ -524,6 +524,7 @@ */ function updateSubject(newSubject) { + // Do not escapeText so that moderators can use fonts and colors Engine.GetGUIObjectByName("subject").caption = newSubject; // If the subject is only whitespace, hide it and reposition the logo. @@ -611,7 +612,7 @@ warn("Unknown presence:" + player.presence); let statusColor = g_PlayerStatuses[presence].color; - let coloredName = colorPlayerName((player.role == "moderator" ? g_ModeratorPrefix : "") + player.name); + let coloredName = colorPlayerName((player.role == "moderator" ? g_ModeratorPrefix : "") + escapeText(player.name)); let coloredPresence = '[color="' + statusColor + '"]' + g_PlayerStatuses[presence].status + "[/color]"; let coloredRating = '[color="' + statusColor + '"]' + rating + "[/color]"; @@ -745,7 +746,7 @@ Engine.SendGetProfile(playerName); - Engine.GetGUIObjectByName("usernameText").caption = playerName; + Engine.GetGUIObjectByName("usernameText").caption = escapeText(playerName); Engine.GetGUIObjectByName("rankText").caption = translate("N/A"); Engine.GetGUIObjectByName("highestRatingText").caption = translate("N/A"); Engine.GetGUIObjectByName("totalGamesText").caption = translate("N/A"); @@ -768,7 +769,7 @@ { let attributes = Engine.GetProfile()[0]; - let user = colorPlayerName(attributes.player, attributes.rating); + let user = colorPlayerName(escapeText(attributes.player), attributes.rating); if (!Engine.GetGUIObjectByName("profileFetch").hidden) { @@ -780,7 +781,7 @@ { Engine.GetGUIObjectByName("profileErrorText").caption = sprintf( translate("Player \"%(nick)s\" not found."), - { "nick": attributes.player } + { "nick": escapeText(attributes.player) } ); return; } @@ -832,7 +833,7 @@ for (let i in boardList) { - list_name.push(boardList[i].name); + list_name.push(escapeText(boardList[i].name)); list_rating.push(boardList[i].rating); list_rank.push(+i+1); list.push(boardList[i].name); Index: binaries/data/mods/public/gui/replaymenu/replay_menu.js =================================================================== --- binaries/data/mods/public/gui/replaymenu/replay_menu.js +++ binaries/data/mods/public/gui/replaymenu/replay_menu.js @@ -110,11 +110,7 @@ if (!playerData || playerData.AI) continue; - // Remove rating from nick - let playername = playerData.Name; - let ratingStart = playername.indexOf(" ("); - if (ratingStart != -1) - playername = playername.substr(0, ratingStart); + let playername = splitRatingFromNick(playerData.Name)[0]; if (g_Playernames.indexOf(playername) == -1) g_Playernames.push(playername); @@ -306,7 +302,7 @@ */ function getReplayPlayernames(replay) { - return replay.attribs.settings.PlayerData.map(pData => pData.Name).join(", "); + return replay.attribs.settings.PlayerData.map(pData => escapeText(pData.Name)).join(", "); } /**