From 30e24069bc41591eac1eb6795865dec8476d26d5 Mon Sep 17 00:00:00 2001 From: Claire Elford Date: Sat, 7 Sep 2024 12:45:10 +1000 Subject: [PATCH] Fix missing character before a Matrix ID When you send messages like "a @blankeclair:catgirl.cloud b" or "]#rainversewiki:catgirl.cloud", they would be rendered like "a@blankeclair:catgirl.cloud b" and "#rainversewiki:catgirl.cloud" respectively. This commit fixes that by not matching the character before the MXID in the regex. --- src/texthandler.cpp | 2 +- src/utils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/texthandler.cpp b/src/texthandler.cpp index 5b45966b8..3c45545a9 100644 --- a/src/texthandler.cpp +++ b/src/texthandler.cpp @@ -626,7 +626,7 @@ QString TextHandler::linkifyUrls(QString stringIn) int skip = 0; if (match.captured(0).size() > 0) { if (stringIn.left(index).count(QStringLiteral("")) == stringIn.left(index).count(QStringLiteral(""))) { - auto replacement = QStringLiteral("%1").arg(match.captured(2)); + auto replacement = QStringLiteral("%1").arg(match.captured(1)); stringIn = stringIn.replace(index, match.captured(0).size(), replacement); } else { skip = match.captured().length(); diff --git a/src/utils.h b/src/utils.h index d07007e71..3447310eb 100644 --- a/src/utils.h +++ b/src/utils.h @@ -80,6 +80,6 @@ static const QRegularExpression QRegularExpression::CaseInsensitiveOption | QRegularExpression::UseUnicodePropertiesOption); static const QRegularExpression emailAddress(QStringLiteral(R"((*SKIP)(*F)|\b(mailto:)?((\w|\.|-)+@(\w|\.|-)+\.\w+\b))"), QRegularExpression::CaseInsensitiveOption | QRegularExpression::UseUnicodePropertiesOption); -static const QRegularExpression mxId(QStringLiteral(R"((^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"), +static const QRegularExpression mxId(QStringLiteral(R"((?<=^|[][[:space:](){}`'";])([!#@][-a-z0-9_=#/.]{1,252}:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?))"), QRegularExpression::CaseInsensitiveOption | QRegularExpression::UseUnicodePropertiesOption); }