diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-03-24 18:51:08 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-03-24 18:51:08 +0900 |
commit | 866b3d2155c0c7f2a58bb1a3c6355129361cb53a (patch) | |
tree | ae57e81166a999360eab39c040e8cbca835721ab /lib/util.cpp | |
parent | 23352250c9b9f9fa7d1d46294f8c1a7de1e19f61 (diff) | |
download | libquotient-866b3d2155c0c7f2a58bb1a3c6355129361cb53a.tar.gz libquotient-866b3d2155c0c7f2a58bb1a3c6355129361cb53a.zip |
linkifyUrls(): fix linkification of emails containing "www."
Closes #303.
Diffstat (limited to 'lib/util.cpp')
-rw-r--r-- | lib/util.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/util.cpp b/lib/util.cpp index 6ed93ba0..8d16cfc8 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -38,14 +38,14 @@ static void linkifyUrls(QString& htmlEscapedText) // comma or dot // Note: outer parentheses are a part of C++ raw string delimiters, not of // the regex (see http://en.cppreference.com/w/cpp/language/string_literal). - // Note2: yet another pair of outer parentheses are \1 in the replacement. + // Note2: the next-outer parentheses are \N in the replacement. static const QRegularExpression FullUrlRegExp(QStringLiteral( - R"(((www\.(?!\.)|(https?|ftp|magnet)://)(&(?![lg]t;)|[^&\s<>'"])+(&(?![lg]t;)|[^&!,.\s<>'"\]):])))" + R"(\b((www\.(?!\.)(?!(\w|\.|-)+@)|(https?|ftp|magnet)://)(&(?![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"((mailto:)?(\b(\w|\.|-)+@(\w|\.|-)+\.\w+\b))" + R"(\b(mailto:)?((\w|\.|-)+@(\w|\.|-)+\.\w+\b))" ), RegExpOptions); // An interim liberal implementation of // https://matrix.org/docs/spec/appendices.html#identifier-grammar @@ -53,7 +53,7 @@ static void linkifyUrls(QString& htmlEscapedText) R"((^|[^<>/])([!#@][-a-z0-9_=/.]{1,252}:[-.a-z0-9]+))" ), RegExpOptions); - // NOTE: htmlEscapedText is already HTML-escaped! No literal <,>,& + // NOTE: htmlEscapedText is already HTML-escaped! No literal <,>,&," htmlEscapedText.replace(EmailAddressRegExp, QStringLiteral(R"(<a href="mailto:\2">\1\2</a>)")); |