aboutsummaryrefslogtreecommitdiff
path: root/lib/util.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-07-09 11:49:05 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-07-09 11:49:05 +0900
commit31e28e2a99e6815da407d201e7287423a4956138 (patch)
tree049f3b156ad2cca3f328d163c9267ae90d984485 /lib/util.cpp
parentb5dd30189df0d7515116b2abac1f93fc0f8a1989 (diff)
parent651478c1681ba6f93e22c20328a048dbbc263ffe (diff)
downloadlibquotient-31e28e2a99e6815da407d201e7287423a4956138.tar.gz
libquotient-31e28e2a99e6815da407d201e7287423a4956138.zip
Merge branch 'master' into use-clang-format
Diffstat (limited to 'lib/util.cpp')
-rw-r--r--lib/util.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/util.cpp b/lib/util.cpp
index 4a7e0f61..9e0807c6 100644
--- a/lib/util.cpp
+++ b/lib/util.cpp
@@ -45,7 +45,7 @@ void QMatrixClient::linkifyUrls(QString& htmlEscapedText)
// comma or dot
static const QRegularExpression FullUrlRegExp(
QStringLiteral(
- R"(\b((www\.(?!\.)(?!(\w|\.|-)+@)|(https?|ftp|magnet)://)(&(?![lg]t;)|[^&\s<>'"])+(&(?![lg]t;)|[^&!,.\s<>'"\]):])))"),
+ R"(\b((www\.(?!\.)(?!(\w|\.|-)+@)|(https?|ftp|magnet|matrix):(//)?)(&(?![lg]t;)|[^&\s<>'"])+(&(?![lg]t;)|[^&!,.\s<>'"\]):])))"),
RegExpOptions);
// email address:
// [word chars, dots or dashes]@[word chars, dots or dashes].[word chars]
@@ -113,6 +113,21 @@ qreal QMatrixClient::stringToHueF(const QString& string)
return hueF;
}
+static const auto ServerPartRegEx = QStringLiteral(
+ "(\\[[^]]+\\]|[^:@]+)" // Either IPv6 address or hostname/IPv4 address
+ "(?::(\\d{1,5}))?" // Optional port
+);
+
+QString QMatrixClient::serverPart(const QString& mxId)
+{
+ static QString re = "^[@!#$+].+?:(" // Localpart and colon
+ % ServerPartRegEx % ")$";
+ static QRegularExpression parser(
+ re,
+ QRegularExpression::UseUnicodePropertiesOption); // Because Asian digits
+ return parser.match(mxId).captured(1);
+}
+
// Tests for function_traits<>
#ifdef Q_CC_CLANG