Added:
All checks were successful
Build Mau & Deploy Mau / build (push) Successful in 1m33s
Build Mau & Deploy Mau / deploy (push) Has been skipped

- Chat message cleaning to prevent HTML injection
- Player hand size to game state
- Deck automatically creates sets when it doesnt have any cards left
This commit is contained in:
DTieman
2024-04-21 16:27:58 +02:00
parent 1e51defad5
commit 3c2032a800
3 changed files with 26 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
using System.Net.WebSockets;
using System.Text.Json;
using System.Text.RegularExpressions;
using MauMau_Server.Mau;
namespace MauMau_Server.Websockets;
@@ -45,7 +46,12 @@ public class Room
}
case "CHAT":
{
_chat.SendChatMessage(connection, message.Payload);
var cleanedMessage = StripHTML(message.Payload);
if (string.IsNullOrWhiteSpace(cleanedMessage))
{
cleanedMessage = "Mau!";
};
_chat.SendChatMessage(connection, cleanedMessage);
break;
}
}
@@ -103,4 +109,9 @@ public class Room
{
return _connections.Count == 0;
}
private static string StripHTML(string input)
{
return Regex.Replace(input, "<.*?>", String.Empty);
}
}