Skip to content

The Free Software Media System - Server Backend & API

detect invalid json with web socket messages

Luke Pulverenti59f24493ce9b
diff --git a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs
index 3612b85b95..4bab10ee09 100644
--- a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs
+++ b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs
@@ -132,10 +132,17 @@ namespace MediaBrowser.Server.Implementations.ServerManager
{
LastActivityDate = DateTime.UtcNow;
+ if (!message.StartsWith("{", StringComparison.OrdinalIgnoreCase))
+ {
+ _logger.Error("Received web socket message that is not a json structure: " + message);
+ return;
+ }
+
if (OnReceive == null)
{
return;
}
+
try
{
var stub = (WebSocketMessage<object>)_jsonSerializer.DeserializeFromString(message, typeof(WebSocketMessage<object>));