@@ -25,10 +25,24 @@ const log = Logging.get("MatrixRoomHandler");
2525
2626const ACCOUNT_LOCK_MS = 1000 ;
2727const EVENT_MAPPING_SIZE = 16384 ;
28+ const XEP0106_ESCAPING_TRANSFORMATIONS = {
29+ '"' : "\\22" ,
30+ "&" : "\\26" ,
31+ "'" : "\\27" ,
32+ "/" : "\\2f" ,
33+ ":" : "\\3a" ,
34+ "<" : "\\3c" ,
35+ ">" : "\\3e" ,
36+ "@" : "\\40" ,
37+ } ;
38+
39+ export function XEP0106ApplyEscapingTransformations ( roomId : string ) : string {
40+ return roomId
41+ . split ( "" )
42+ . map ( char => XEP0106_ESCAPING_TRANSFORMATIONS [ char ] || char )
43+ . join ( "" ) ;
44+ }
2845
29- /**
30- * Handles creation and handling of rooms.
31- */
3246export class MatrixRoomHandler {
3347 private bridge : Bridge ;
3448 private accountRoomLock : Set < string > ;
@@ -161,6 +175,8 @@ export class MatrixRoomHandler {
161175 log . info ( "User joined, can now send messages" ) ;
162176 }
163177 this . roomCreationLock . delete ( remoteId ) ;
178+ roomId = XEP0106ApplyEscapingTransformations ( roomId ! ) ;
179+
164180 return roomId ! ;
165181 }
166182
@@ -221,6 +237,8 @@ export class MatrixRoomHandler {
221237 throw Error ( "Room doesn't exist, refusing to make room" ) ;
222238 }
223239 log . info ( `Found ${ roomId } for ${ alias } ` ) ;
240+ roomId = XEP0106ApplyEscapingTransformations ( roomId ) ;
241+
224242 return roomId ;
225243 }
226244
@@ -251,6 +269,8 @@ export class MatrixRoomHandler {
251269 this . roomCreationLock . set ( remoteId , createPromise as Promise < any > ) ;
252270 await createPromise ;
253271 this . roomCreationLock . delete ( remoteId ) ;
272+ roomId = XEP0106ApplyEscapingTransformations ( roomId ) ;
273+
254274 return roomId ;
255275 }
256276
0 commit comments