More linkifier fixes

* Accept underscores in usernames
 * Accept usernames & room aliases on localhost
 * Accept #localhost:foo.com and @localhost:foo.com
pull/21833/head
David Baker 2016-09-23 14:02:14 +01:00
parent fae9b048dd
commit 2120963c7a
1 changed files with 11 additions and 1 deletions

View File

@ -45,6 +45,10 @@ function matrixLinkify(linkify) {
TT.TLD, TT.TLD,
TT.UNDERSCORE, TT.UNDERSCORE,
TT.POUND, 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); 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.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.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.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.DOMAIN, S_HASH_NAME_COLON_DOMAIN);
S_HASH_NAME_COLON_DOMAIN_DOT.on(TT.TLD, S_ROOMALIAS); S_HASH_NAME_COLON_DOMAIN_DOT.on(TT.TLD, S_ROOMALIAS);
@ -77,10 +82,14 @@ function matrixLinkify(linkify) {
var username_tokens = [ var username_tokens = [
TT.DOT, TT.DOT,
TT.UNDERSCORE,
TT.PLUS, TT.PLUS,
TT.NUM, TT.NUM,
TT.DOMAIN, TT.DOMAIN,
TT.TLD TT.TLD,
// as in roomname_tokens
TT.LOCALHOST,
]; ];
S_START.on(TT.AT, S_AT); 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.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.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.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.DOMAIN, S_AT_NAME_COLON_DOMAIN);
S_AT_NAME_COLON_DOMAIN_DOT.on(TT.TLD, S_USERID); S_AT_NAME_COLON_DOMAIN_DOT.on(TT.TLD, S_USERID);