From b73cf4782a352595c95cae4847a2dfdacf337a26 Mon Sep 17 00:00:00 2001 From: Ryan Freeman Date: Fri, 21 Jun 2024 16:11:21 +0100 Subject: [PATCH] Fixed new line character skipping \n\r handles in both directions as well \r\n as well as just \n or \r --- .../protocol/loconet/iohandler/lbserveriohandler.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/src/hardware/protocol/loconet/iohandler/lbserveriohandler.cpp b/server/src/hardware/protocol/loconet/iohandler/lbserveriohandler.cpp index e9d08651..48d389ca 100644 --- a/server/src/hardware/protocol/loconet/iohandler/lbserveriohandler.cpp +++ b/server/src/hardware/protocol/loconet/iohandler/lbserveriohandler.cpp @@ -145,8 +145,11 @@ void LBServerIOHandler::read() m_version = line.substr(7); } - pos += line.size(); - bytesTransferred -= line.size(); + pos = eol + 1; // Skip the newline character + if (pos < end && (*pos == '\n' || *pos == '\r') && *pos != *(pos - 1)) { + pos++; // Skip the second part of CRLF or LFCR + } + bytesTransferred = end - pos; } if(bytesTransferred != 0)