From a6f21b6606846a92df8d539d0500f87a5664939f Mon Sep 17 00:00:00 2001 From: Chuang Zhu Date: Mon, 4 Jul 2022 22:20:11 +0800 Subject: [PATCH] Fix parsing encoded matrix.to URL (#660) From https://spec.matrix.org/v1.3/appendices/#matrixto-navigation: The components of the matrix.to URI ( and ) are to be percent-encoded as per RFC 3986. Historically, clients have not produced URIs which are fully encoded. Clients should try to interpret these cases to the best of their ability. For example, an unencoded room alias should still work within the client if possible --- src/util/sanitize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/sanitize.js b/src/util/sanitize.js index 3b230523..5351a1a0 100644 --- a/src/util/sanitize.js +++ b/src/util/sanitize.js @@ -44,7 +44,7 @@ function transformSpanTag(tagName, attribs) { } function transformATag(tagName, attribs) { - const userLink = attribs.href.match(/^https?:\/\/matrix.to\/#\/(@.+:.+)/); + const userLink = decodeURIComponent(attribs.href).match(/^https?:\/\/matrix.to\/#\/(@.+:.+)/); if (userLink !== null) { // convert user link to pill const userId = userLink[1];