Added:
- 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:
13
Room/Room.cs
13
Room/Room.cs
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user