Fix chat sanitization and entity name escaping (#12015)

This commit is contained in:
Leon Friedrich
2022-10-18 19:59:09 +13:00
committed by GitHub
parent 6db886773b
commit 3aeba9a63e
11 changed files with 104 additions and 94 deletions

View File

@@ -23,9 +23,9 @@ namespace Content.Client.Chat
public ChatChannel Channel { get; set; }
/// <summary>
/// What to "wrap" the message contents with. Example is stuff like 'Joe says: "{0}"'
/// Modified message with some wrapping text. E.g. 'Joe says: "HELP!"'
/// </summary>
public string MessageWrap { get; set; }
public string WrappedMessage { get; set; }
/// <summary>
/// The override color of the message
@@ -44,7 +44,7 @@ namespace Content.Client.Chat
{
Message = netMsg.Message;
Channel = netMsg.Channel;
MessageWrap = netMsg.MessageWrap;
WrappedMessage = netMsg.WrappedMessage;
MessageColorOverride = netMsg.MessageColorOverride;
}
}

View File

@@ -46,13 +46,7 @@ public partial class ChatBox : UIWidget
private void OnMessageAdded(StoredChatMessage msg)
{
var text = FormattedMessage.EscapeText(msg.Message);
if (!string.IsNullOrEmpty(msg.MessageWrap))
{
text = string.Format(msg.MessageWrap, text);
}
Logger.DebugS("chat", $"{msg.Channel}: {text}");
Logger.DebugS("chat", $"{msg.Channel}: {msg.Message}");
if (!ChatInput.FilterButton.ChatFilterPopup.IsActive(msg.Channel))
{
return;
@@ -64,7 +58,7 @@ public partial class ChatBox : UIWidget
? msg.MessageColorOverride
: msg.Channel.TextColor();
AddLine(text, color);
AddLine(msg.WrappedMessage, color);
}
private void OnChannelSelect(ChatSelectChannel channel)