From db5612ed9734d51e6fcd0d7b5a7635e49b773581 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Fri, 22 Nov 2024 22:42:22 +0200 Subject: Character safety checking, supported terminals updated --- src/scalevalapokalypsi/Server/Client.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/scalevalapokalypsi/Server/Client.scala') diff --git a/src/scalevalapokalypsi/Server/Client.scala b/src/scalevalapokalypsi/Server/Client.scala index d689356..5727fc6 100644 --- a/src/scalevalapokalypsi/Server/Client.scala +++ b/src/scalevalapokalypsi/Server/Client.scala @@ -3,6 +3,7 @@ package scalevalapokalypsi.Server import java.net.Socket import scala.math.{min,max} import scalevalapokalypsi.constants.* +import scalevalapokalypsi.utils.* import ServerProtocolState.* import scalevalapokalypsi.Model.Action import scalevalapokalypsi.Model.Entities.Player @@ -113,8 +114,7 @@ class Client(val socket: Socket): val rest = this.incompleteMessage.drop(nextCRLF + 2) this.incompleteMessage = rest ++ Array.fill(nextCRLF + 1)(0.toByte) this.incompleteMessageIndex = 0 - // TODO: the conversion may probably be exploited to crash the server - Some(String(message)) + byteArrayToString(message) else None @@ -178,7 +178,7 @@ class Client(val socket: Socket): this.singStartTime = None - case None => + case None if isPrintable(line) => val action = Action(line) val takesATurn = this.character.exists(p => action.execute(p)) @@ -186,6 +186,10 @@ class Client(val socket: Socket): this.addDataToSend(s"$ACTION_BLOCKING_INDICATOR") this.turnUsed = true + case None => + + () // There were some illegal chars but whatever + end executeLine end Client -- cgit v1.2.3