From 0af420b8243453ddf3056bad74d55f343221ca0e Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 22 Jan 2023 18:35:31 +0000 Subject: [PATCH] Improve link regex to fix handling paranthesis and question marks This patch fixes two key issues: * `?` is considered part of the URL, even if there might not be anything past it. I've seen people now putting spaces after URLs to get around this issue. * `)` is also part of the URL, as well as `:` despite those not being valid characters at the end of URLs. --- src/qml/Component/Timeline/RichLabel.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/Component/Timeline/RichLabel.qml b/src/qml/Component/Timeline/RichLabel.qml index 76f226a97..6a623c40a 100644 --- a/src/qml/Component/Timeline/RichLabel.qml +++ b/src/qml/Component/Timeline/RichLabel.qml @@ -17,7 +17,7 @@ TextEdit { property bool isEmote: false property bool isReplyLabel: false - readonly property var linkRegex: /(href=["'])?(\b(https?):\/\/[^\s\<\>\"\'\\]+)/g + readonly property var linkRegex: /(href=["'])?(\b(https?):\/\/[^\s\<\>\"\'\\\?\:\)\(]+(\(.*?\))*(\?(?=[a-z])[^\s\\\)]+|$)?)/g property string textMessage: model.display.includes("http") ? model.display.replace(linkRegex, function() { if (arguments[0].includes("/_matrix/media/r0/download/")) {