aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/connection.cpp2
-rw-r--r--lib/util.cpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index d3324d47..0f53643b 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -1151,7 +1151,7 @@ User* Connection::user(const QString& uId)
{
if (uId.isEmpty())
return nullptr;
- if (!uId.startsWith('@') || !uId.contains(':')) {
+ if (!uId.startsWith('@') || serverPart(uId).isEmpty()) {
qCCritical(MAIN) << "Malformed userId:" << uId;
return nullptr;
}
diff --git a/lib/util.cpp b/lib/util.cpp
index 797f6d69..023645c1 100644
--- a/lib/util.cpp
+++ b/lib/util.cpp
@@ -116,13 +116,13 @@ qreal Quotient::stringToHueF(const QString& s)
}
static const auto ServerPartRegEx = QStringLiteral(
- "(\\[[^]]+\\]|[^:@]+)" // Either IPv6 address or hostname/IPv4 address
+ "(\\[[^][:blank:]]+\\]|[-[:alnum:].]+)" // Either IPv6 address or hostname/IPv4 address
"(?::(\\d{1,5}))?" // Optional port
);
QString Quotient::serverPart(const QString& mxId)
{
- static QString re = "^[@!#$+].+?:(" // Localpart and colon
+ static QString re = "^[@!#$+].*?:(" // Localpart and colon
% ServerPartRegEx % ")$";
static QRegularExpression parser(
re,