diff --git a/Quotient/util.cpp b/Quotient/util.cpp index a079ee1e9..4a9b97795 100644 --- a/Quotient/util.cpp +++ b/Quotient/util.cpp @@ -32,10 +32,8 @@ void Quotient::linkifyUrls(QString& htmlEscapedText) QStringLiteral( R"(\b((www\.(?!\.)(?!(\w|\.|-)+@)|(https?|ftp):(//)?\w|(magnet|matrix):)(&(?![lg]t;)|[^&\s<>'"])+(&(?![lg]t;)|[^&!,.\s<>'"\]):])))"), RegExpOptions); - // email address: - // [word chars, dots or dashes]@[word chars, dots or dashes].[word chars] static const QRegularExpression EmailAddressRegExp( - QStringLiteral(R"(\b(mailto:)?((\w|\.|-)+@(\w|\.|-)+\.\w+\b))"), + QStringLiteral(R"((^|[][[:space:](){}`'";<>])(mailto:)?((\w|[!#$%&'*+=^_‘{|}~.-])+@(\w|\.|-)+\.\w+\b))"), RegExpOptions); // An interim liberal implementation of // https://matrix.org/docs/spec/appendices.html#identifier-grammar @@ -49,7 +47,7 @@ void Quotient::linkifyUrls(QString& htmlEscapedText) // NOTE: htmlEscapedText is already HTML-escaped! No literal <,>,&," htmlEscapedText.replace(EmailAddressRegExp, - R"(\1\2)"_ls); + R"(\1\2\3)"_ls); htmlEscapedText.replace(FullUrlRegExp, R"(\1)"_ls); htmlEscapedText.replace(MxIdRegExp, R"(\1\2)"_ls);