From 58fee9705d3b802aa2abb5201a1afaa454cc2caa Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Sun, 11 Apr 2021 13:24:41 +0200 Subject: [PATCH] CHANGE(server): Untrimmed usernames considered invalid When checking whether a given username is valid, it being trimmed is now also a criterion. All names with leading and/or trailing whitespace will be considered invalid from now on. --- src/murmur/Server.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 2e71fd798..05790548d 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -2092,7 +2092,9 @@ QString Server::addressToString(const QHostAddress &adr, unsigned short port) { } bool Server::validateUserName(const QString &name) { - return (qrUserName.exactMatch(name) && (name.length() <= 512)); + // We expect the name passed to this function to be fully trimmed already. This way we + // prevent "empty" names (at least with the default username restriction). + return (name.trimmed().length() == name.length() && qrUserName.exactMatch(name) && (name.length() <= 512)); } bool Server::validateChannelName(const QString &name) {