From 59117f1905b5eb3b2b6fb9b998d30ef919279a71 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 21 Sep 2016 14:11:43 +0100 Subject: [PATCH 1/3] Fix linkifying rooms with underscores, try 2 Fixes https://github.com/vector-im/vector-web/issues/500 --- package.json | 2 +- src/linkify-matrix.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fcd09f71e4..b30307eec0 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "fuse.js": "^2.2.0", "glob": "^5.0.14", "highlight.js": "^8.9.1", - "linkifyjs": "2.0.0-beta.4", + "linkifyjs": "^2.1.0", "lodash": "^4.13.1", "marked": "^0.3.5", "matrix-js-sdk": "matrix-org/matrix-js-sdk#develop", diff --git a/src/linkify-matrix.js b/src/linkify-matrix.js index 99e4898182..1e93d8c387 100644 --- a/src/linkify-matrix.js +++ b/src/linkify-matrix.js @@ -42,7 +42,9 @@ function matrixLinkify(linkify) { TT.PLUS, TT.NUM, TT.DOMAIN, - TT.TLD + TT.TLD, + TT.UNDERSCORE, + TT.POUND, ]; S_START.on(TT.POUND, S_HASH); From 2120963c7a7eee0d9e4db115abb6b6e9eb63431c Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 23 Sep 2016 14:02:14 +0100 Subject: [PATCH 2/3] More linkifier fixes * Accept underscores in usernames * Accept usernames & room aliases on localhost * Accept #localhost:foo.com and @localhost:foo.com --- src/linkify-matrix.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/linkify-matrix.js b/src/linkify-matrix.js index 1e93d8c387..8dceb3a527 100644 --- a/src/linkify-matrix.js +++ b/src/linkify-matrix.js @@ -45,6 +45,10 @@ function matrixLinkify(linkify) { TT.TLD, TT.UNDERSCORE, TT.POUND, + + // because 'localhost' is tokenised to the localhost token, + // usernames @localhost:foo.com are otherwise not matched! + TT.LOCALHOST, ]; S_START.on(TT.POUND, S_HASH); @@ -56,6 +60,7 @@ function matrixLinkify(linkify) { S_HASH_NAME.on(TT.COLON, S_HASH_NAME_COLON); S_HASH_NAME_COLON.on(TT.DOMAIN, S_HASH_NAME_COLON_DOMAIN); + S_HASH_NAME_COLON.on(TT.LOCALHOST, S_ROOMALIAS); // accept #foo:localhost S_HASH_NAME_COLON_DOMAIN.on(TT.DOT, S_HASH_NAME_COLON_DOMAIN_DOT); S_HASH_NAME_COLON_DOMAIN_DOT.on(TT.DOMAIN, S_HASH_NAME_COLON_DOMAIN); S_HASH_NAME_COLON_DOMAIN_DOT.on(TT.TLD, S_ROOMALIAS); @@ -77,10 +82,14 @@ function matrixLinkify(linkify) { var username_tokens = [ TT.DOT, + TT.UNDERSCORE, TT.PLUS, TT.NUM, TT.DOMAIN, - TT.TLD + TT.TLD, + + // as in roomname_tokens + TT.LOCALHOST, ]; S_START.on(TT.AT, S_AT); @@ -92,6 +101,7 @@ function matrixLinkify(linkify) { S_AT_NAME.on(TT.COLON, S_AT_NAME_COLON); S_AT_NAME_COLON.on(TT.DOMAIN, S_AT_NAME_COLON_DOMAIN); + S_AT_NAME_COLON.on(TT.LOCALHOST, S_USERID); // accept @foo:localhost S_AT_NAME_COLON_DOMAIN.on(TT.DOT, S_AT_NAME_COLON_DOMAIN_DOT); S_AT_NAME_COLON_DOMAIN_DOT.on(TT.DOMAIN, S_AT_NAME_COLON_DOMAIN); S_AT_NAME_COLON_DOMAIN_DOT.on(TT.TLD, S_USERID); From 898d792336318e4e7d5662ee6e7dc39527d74821 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 23 Sep 2016 14:05:31 +0100 Subject: [PATCH 3/3] Update to linkifyjs 2.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 892fbecdf8..d82ec90c58 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "fuse.js": "^2.2.0", "glob": "^5.0.14", "highlight.js": "^8.9.1", - "linkifyjs": "^2.1.0", + "linkifyjs": "^2.1.1", "lodash": "^4.13.1", "marked": "^0.3.5", "matrix-js-sdk": "matrix-org/matrix-js-sdk#develop",