@@ -41,6 +41,21 @@ describe("resolveMentions", () => {
4141 mentionedUserId : "@bot:matrix.org" ,
4242 body : "hello @bot:matrix.org" ,
4343 } ,
44+ {
45+ label : "colon-delimited full Matrix user ID" ,
46+ mentionedUserId : "@bot:matrix.org" ,
47+ body : "@bot:matrix.org: help" ,
48+ } ,
49+ {
50+ label : "Unicode-whitespace-colon-delimited full Matrix user ID" ,
51+ mentionedUserId : "@bot:matrix.org" ,
52+ body : "@bot:matrix.org:\u2003help" ,
53+ } ,
54+ {
55+ label : "colon-delimited full Matrix user ID with a homeserver port" ,
56+ mentionedUserId : "@bot:matrix.org:8448" ,
57+ body : "@bot:matrix.org:8448: help" ,
58+ } ,
4459 {
4560 label : "localpart shorthand" ,
4661 mentionedUserId : "@bot:matrix.org" ,
@@ -86,6 +101,11 @@ describe("resolveMentions", () => {
86101 mentionedUserId : "@bot:[2001:db8::1]:8448" ,
87102 body : "hello @bot:[2001:db8::1]:8448" ,
88103 } ,
104+ {
105+ label : "colon-delimited bracketed IPv6 homeserver and port" ,
106+ mentionedUserId : "@bot:[2001:db8::1]:8448" ,
107+ body : "@bot:[2001:db8::1]:8448:\u2003help" ,
108+ } ,
89109 ] ) (
90110 "detects native plain-text $label without configured mention patterns" ,
91111 ( { mentionedUserId, body } ) => {
@@ -111,6 +131,25 @@ describe("resolveMentions", () => {
111131 { label : "case-different homeserver" , body : "hello @bot:MATRIX.ORG" } ,
112132 { label : "extended DNS homeserver" , body : "hello @bot:matrix.org.evil" } ,
113133 { label : "unexpected homeserver port" , body : "hello @bot:matrix.org:8448" } ,
134+ { label : "unexpected homeserver port before a command" , body : "@bot:matrix.org:8448: help" } ,
135+ { label : "unexpected repeated homeserver colon" , body : "@bot:matrix.org::8448" } ,
136+ { label : "full Matrix user ID followed by colon alone" , body : "@bot:matrix.org:" } ,
137+ {
138+ label : "full Matrix user ID followed by invisible BOM" ,
139+ body : "@bot:matrix.org:\ufeffhelp" ,
140+ } ,
141+ {
142+ label : "full Matrix user ID followed by invisible zero-width text" ,
143+ body : "@bot:matrix.org:\u200bhelp" ,
144+ } ,
145+ {
146+ label : "full Matrix user ID followed by bidirectional formatting" ,
147+ body : "@bot:matrix.org:\u202ehelp" ,
148+ } ,
149+ {
150+ label : "full Matrix user ID followed by a hidden control" ,
151+ body : "@bot:matrix.org:\u0001help" ,
152+ } ,
114153 { label : "alternate IPv6 homeserver" , body : "hello @bot:[::1]" } ,
115154 { label : "extended dotted localpart" , body : "hello @bot.extra" } ,
116155 { label : "extended plus localpart" , body : "hello @bot+evil" } ,
@@ -133,6 +172,7 @@ describe("resolveMentions", () => {
133172 { label : "ambiguous Markdown-wrapped shorthand" , body : "hello **@bot**" } ,
134173 { label : "ambiguous hash-wrapped shorthand" , body : "hello #@bot#" } ,
135174 { label : "Matrix room-alias account collision" , body : "hello #@bot:matrix.org" } ,
175+ { label : "Matrix room-alias colon-command collision" , body : "#@bot:matrix.org: help" } ,
136176 { label : "Matrix room-ID account collision" , body : "hello !@bot:matrix.org" } ,
137177 { label : "Matrix event-ID account collision" , body : "hello $@bot:matrix.org" } ,
138178 { label : "unseparated Unicode punctuation" , body : "hello (@bot),thanks" } ,
0 commit comments