From 96163d14025ed9cc3707ba52b255c31bc1bbe9c4 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 26 Jun 2018 23:41:46 +0100 Subject: [PATCH] prevent multiple ports (:1234:1234:1234) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/linkify-matrix.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/linkify-matrix.js b/src/linkify-matrix.js index 637b5869ef..50d50f219a 100644 --- a/src/linkify-matrix.js +++ b/src/linkify-matrix.js @@ -42,6 +42,7 @@ function matrixLinkify(linkify) { const S_HASH_NAME_COLON_DOMAIN_DOT = new linkify.parser.State(); const S_ROOMALIAS = new linkify.parser.State(ROOMALIAS); const S_ROOMALIAS_COLON = new linkify.parser.State(); + const S_ROOMALIAS_COLON_NUM = new linkify.parser.State(ROOMALIAS); const roomname_tokens = [ TT.DOT, @@ -72,7 +73,7 @@ function matrixLinkify(linkify) { S_ROOMALIAS.on(TT.DOT, S_HASH_NAME_COLON_DOMAIN_DOT); // accept repeated TLDs (e.g .org.uk) S_ROOMALIAS.on(TT.COLON, S_ROOMALIAS_COLON); // do not accept trailing `:` - S_ROOMALIAS_COLON.on(TT.NUM, S_ROOMALIAS); // but do accept :NUM (port specifier) + S_ROOMALIAS_COLON.on(TT.NUM, S_ROOMALIAS_COLON_NUM); // but do accept :NUM (port specifier) const USERID = function(value) { @@ -89,6 +90,7 @@ function matrixLinkify(linkify) { const S_AT_NAME_COLON_DOMAIN_DOT = new linkify.parser.State(); const S_USERID = new linkify.parser.State(USERID); const S_USERID_COLON = new linkify.parser.State(); + const S_USERID_COLON_NUM = new linkify.parser.State(USERID); const username_tokens = [ TT.DOT, @@ -117,7 +119,7 @@ function matrixLinkify(linkify) { S_USERID.on(TT.DOT, S_AT_NAME_COLON_DOMAIN_DOT); // accept repeated TLDs (e.g .org.uk) S_USERID.on(TT.COLON, S_USERID_COLON); // do not accept trailing `:` - S_USERID_COLON.on(TT.NUM, S_USERID); // but do accept :NUM (port specifier) + S_USERID_COLON.on(TT.NUM, S_USERID_COLON_NUM); // but do accept :NUM (port specifier) const GROUPID = function(value) { @@ -134,6 +136,7 @@ function matrixLinkify(linkify) { const S_PLUS_NAME_COLON_DOMAIN_DOT = new linkify.parser.State(); const S_GROUPID = new linkify.parser.State(GROUPID); const S_GROUPID_COLON = new linkify.parser.State(); + const S_GROUPID_COLON_NUM = new linkify.parser.State(GROUPID); const groupid_tokens = [ TT.DOT, @@ -162,7 +165,7 @@ function matrixLinkify(linkify) { S_GROUPID.on(TT.DOT, S_PLUS_NAME_COLON_DOMAIN_DOT); // accept repeated TLDs (e.g .org.uk) S_GROUPID.on(TT.COLON, S_GROUPID_COLON); // do not accept trailing `:` - S_GROUPID_COLON.on(TT.NUM, S_GROUPID); // but do accept :NUM (port specifier) + S_GROUPID_COLON.on(TT.NUM, S_GROUPID_COLON_NUM); // but do accept :NUM (port specifier) } // stubs, overwritten in MatrixChat's componentDidMount