From 727049c52681eeccca5d7dbec6997cb6fe92cea1 Mon Sep 17 00:00:00 2001 From: issue Date: Wed, 9 Feb 2022 18:00:32 +0100 Subject: [PATCH] FIX(client): Percent encoded links not clickable If a link contains any percent encoded characters (e.g. umlauts), the markdown parser sets a wrong offset, thus resulting in a cut off link in the log. This is fixed by adjusting the url parsing regex to include a percent symbol. --- src/mumble/Markdown.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mumble/Markdown.cpp b/src/mumble/Markdown.cpp index 2349a0c2e..2b251a9fb 100644 --- a/src/mumble/Markdown.cpp +++ b/src/mumble/Markdown.cpp @@ -310,9 +310,10 @@ bool processMarkdownCodeBlock(QString &str, int &offset) { /// @returns Whether a replacement has been made bool processPlainLink(QString &str, int &offset) { // We support links with prefixed protocol (e.g. https://bla.com) and prefixed with www (e.g. www.bla.com) + // The last part of the regex matches percent encoded characters in the url // See also https://stackoverflow.com/a/1547940/3907364 static const QRegularExpression s_regex( - QLatin1String("([a-zA-Z]+://|[wW][wW][wW]\\.)[A-Za-z0-9-._~:/?#\\[\\]@!$&'()*+,;=]+")); + QLatin1String("([a-zA-Z]+://|[wW][wW][wW]\\.)([A-Za-z0-9-._~:/?#\\[\\]@!$&'()*+,;=]|%[a-fA-F0-9]{2})+")); QRegularExpressionMatch match = s_regex.match(str, offset, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption);