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.
This commit is contained in:
Robert Adam 2021-04-11 13:24:41 +02:00
parent 90190bcb01
commit 58fee9705d

View File

@ -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) {