From eab1a776838815b4d7b1ac01cc7bcf5f56d3bfd9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 4 Nov 2013 18:11:15 +0100 Subject: ClientRead: always ignore whitespace at the end of the line --- src/ClientRead.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/ClientRead.cxx') diff --git a/src/ClientRead.cxx b/src/ClientRead.cxx index 2bb3c56c0..925e1502d 100644 --- a/src/ClientRead.cxx +++ b/src/ClientRead.cxx @@ -21,6 +21,7 @@ #include "ClientInternal.hxx" #include "Main.hxx" #include "event/Loop.hxx" +#include "util/CharUtil.hxx" #include #include @@ -35,11 +36,15 @@ Client::OnSocketInput(void *data, size_t length) TimeoutMonitor::ScheduleSeconds(client_timeout); + BufferedSocket::ConsumeInput(newline + 1 - p); + + /* skip whitespace at the end of the line */ + while (newline > p && IsWhitespaceOrNull(newline[-1])) + --newline; + /* terminate the string at the end of the line */ *newline = 0; - BufferedSocket::ConsumeInput(newline + 1 - p); - CommandResult result = client_process_line(*this, p); switch (result) { case CommandResult::OK: -- cgit v1.2.3