From 498f6d9e64c984e4e59dc0e731a70d273a23c28b Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 18 Mar 2024 15:46:22 -0400 Subject: [PATCH] Exclude lonely question marks from the linkify regex Many URLs we see in the KDE rooms end with a question mark, without a space. The linkify regex for plain URLs incorrectly considered them as part of the link, which usually breaks them when opened in a web browser. Now the regex excludes these, unless they are accompanied by another character (so links like kde.org/realurl?is=true will still work.) (cherry picked from commit 1b7f482d0bec73a778d6ab8c1dd4960c6a7085d7) --- src/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.h b/src/utils.h index 66d47d775..89af92b50 100644 --- a/src/utils.h +++ b/src/utils.h @@ -37,7 +37,7 @@ static const QRegularExpression strikethrough{QStringLiteral("(.*?)") static const QRegularExpression mxcImage{QStringLiteral(R"AAA()AAA")}; static const QRegularExpression plainUrl( QStringLiteral( - R"((*SKIP)(*F)|\b((www\.(?!\.)(?!(\w|\.|-)+@)|(https?|ftp):(//)?\w|(magnet|matrix):)(&(?![lg]t;)|[^&\s<>'"])+(&(?![lg]t;)|[^&!,.\s<>'"\]):])))"), + R"((*SKIP)(*F)|\b((www\.(?!\.)(?!(\w|\.|-)+@)|(https?|ftp):(//)?\w|(magnet|matrix):)(&(?![lg]t;)|[^&\s<>'"])+(&(?![lg]t;)|[^?&!,.\s<>'"\]):])))"), QRegularExpression::CaseInsensitiveOption | QRegularExpression::UseUnicodePropertiesOption); static const QRegularExpression url(QStringLiteral(R"(\b((www\.(?!\.)(?!(\w|\.|-)+@)|https?:(//)?\w)(&(?![lg]t;)|[^&\s<>'"])+(&(?![lg]t;)|[^&!,.\s<>'"\]):])))"),