aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/Server/Client.scala
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-17 01:59:46 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-17 01:59:46 +0200
commite0e720c1b78506f1f9c00e2d275caa170becc927 (patch)
tree191fca97383d8bab709894f611607e43e0c1b760 /src/main/scala/Server/Client.scala
parent165a89af296cf4f6bff0241477fced2e66e681d4 (diff)
downloadscalevalapokalypsi-e0e720c1b78506f1f9c00e2d275caa170becc927.tar.gz
scalevalapokalypsi-e0e720c1b78506f1f9c00e2d275caa170becc927.zip
Bug fix: Server.Client.nextLine left newlines at starts of lines
Diffstat (limited to 'src/main/scala/Server/Client.scala')
-rw-r--r--src/main/scala/Server/Client.scala7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/scala/Server/Client.scala b/src/main/scala/Server/Client.scala
index d4f1864..7c7a786 100644
--- a/src/main/scala/Server/Client.scala
+++ b/src/main/scala/Server/Client.scala
@@ -99,7 +99,12 @@ class Client(val socket: Socket):
if this.incompleteMessage(nextCRLF + 1) != CRLF(1) then nextCRLF = -1
if nextCRLF != -1 then
val message = this.incompleteMessage.take(nextCRLF)
- val rest = this.incompleteMessage.drop(nextCRLF + 1)
+ val rest = this.incompleteMessage.drop(nextCRLF + 2)
+ assert(rest.headOption != Some(CRLF(1))) // I will compile this with
+ // assertions off... I'd
+ // like to know how to make
+ // tests work with this
+ // config...
this.incompleteMessage = rest ++ Array.fill(nextCRLF + 1)(0.toByte)
// TODO: the conversion may probably be exploited to crash the server
Some(String(message))