From 62bb891e79d879b05c1e19e7d60b530a5969baf0 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 12 May 2021 22:49:34 +0200 Subject: [PATCH] don't accept closing parenthesis as last character of url --- src/domain/session/room/timeline/linkify/linkify.js | 6 ++++++ src/domain/session/room/timeline/linkify/regex.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/domain/session/room/timeline/linkify/linkify.js b/src/domain/session/room/timeline/linkify/linkify.js index 8cea4b28..333705c1 100644 --- a/src/domain/session/room/timeline/linkify/linkify.js +++ b/src/domain/session/room/timeline/linkify/linkify.js @@ -96,6 +96,12 @@ export function tests() { } }, + "Link doesn't adopt closing parenthesis": assert => { + const link = "(https://matrix.org)"; + const out = [{ type: "text", text: "(" }, { type: "link", text: "https://matrix.org" }, { type: "text", text: ")" }]; + test(assert, link, out); + }, + "Unicode in hostname must not linkify": assert => { const link = "https://foo.bar\uD83D\uDE03.com"; const out = [{ type: "link", text: "https://foo.bar" }, diff --git a/src/domain/session/room/timeline/linkify/regex.js b/src/domain/session/room/timeline/linkify/regex.js index 2374ee23..8e75bf91 100644 --- a/src/domain/session/room/timeline/linkify/regex.js +++ b/src/domain/session/room/timeline/linkify/regex.js @@ -4,7 +4,7 @@ meaning that any escapes (\) must also be escaped. */ const scheme = "(?:https|http|ftp):\\/\\/"; -const noSpaceNorPunctuation = "[^\\s.,?!]"; +const noSpaceNorPunctuation = "[^\\s.,?!)]"; const hostCharacter = "[a-zA-Z0-9:.\\[\\]-]"; /*