Browse Source

Fix app crash with special characters in the room name

master
zbettenbuk 7 years ago
parent
commit
fc25125667
1 changed files with 40 additions and 2 deletions
  1. 40
    2
      react/features/base/util/uri.js

+ 40
- 2
react/features/base/util/uri.js View File

6
  */
6
  */
7
 export const APP_LINK_SCHEME = 'org.jitsi.meet:';
7
 export const APP_LINK_SCHEME = 'org.jitsi.meet:';
8
 
8
 
9
+/**
10
+ * A list of characters to be excluded/removed from the room component/segment
11
+ * of a conference/meeting URI/URL. The list is based on RFC 3986 and the jxmpp
12
+ * library utilized by jicofo.
13
+ */
14
+const _ROOM_EXCLUDE_PATTERN = '[\\:\\?#\\[\\]@!$&\'()*+,;=></"]';
15
+
9
 /**
16
 /**
10
  * The {@link RegExp} pattern of the authority of a URI.
17
  * The {@link RegExp} pattern of the authority of a URI.
11
  *
18
  *
34
  */
41
  */
35
 export const URI_PROTOCOL_PATTERN = '([a-z][a-z0-9\\.\\+-]*:)';
42
 export const URI_PROTOCOL_PATTERN = '([a-z][a-z0-9\\.\\+-]*:)';
36
 
43
 
44
+/**
45
+ * Excludes/removes certain characters from a specific room (name) which are
46
+ * incompatible with Jitsi Meet on the client and/or server sides.
47
+ *
48
+ * @param {?string} room - The room (name) to fix.
49
+ * @private
50
+ * @returns {?string}
51
+ */
52
+function _fixRoom(room: ?string) {
53
+    return room
54
+        ? room.replace(new RegExp(_ROOM_EXCLUDE_PATTERN, 'g'), '')
55
+        : room;
56
+}
57
+
37
 /**
58
 /**
38
  * Fixes the hier-part of a specific URI (string) so that the URI is well-known.
59
  * Fixes the hier-part of a specific URI (string) so that the URI is well-known.
39
  * For example, certain Jitsi Meet deployments are not conventional but it is
60
  * For example, certain Jitsi Meet deployments are not conventional but it is
295
     // contextRoot
316
     // contextRoot
296
     obj.contextRoot = getLocationContextRoot(obj);
317
     obj.contextRoot = getLocationContextRoot(obj);
297
 
318
 
298
-    // The room (name) is the last component of pathname.
319
+    // The room (name) is the last component/segment of pathname.
299
     const { pathname } = obj;
320
     const { pathname } = obj;
300
 
321
 
301
-    obj.room = pathname.substring(pathname.lastIndexOf('/') + 1) || undefined;
322
+    // XXX While the components/segments of pathname are URI encoded, Jitsi Meet
323
+    // on the client and/or server sides still don't support certain characters.
324
+    const contextRootEndIndex = pathname.lastIndexOf('/');
325
+    let room = pathname.substring(contextRootEndIndex + 1) || undefined;
326
+
327
+    if (room) {
328
+        const fixedRoom = _fixRoom(room);
329
+
330
+        if (fixedRoom !== room) {
331
+            room = fixedRoom;
332
+
333
+            // XXX Drive fixedRoom into pathname (because room is derived from
334
+            // pathname).
335
+            obj.pathname
336
+                = pathname.substring(0, contextRootEndIndex + 1) + (room || '');
337
+        }
338
+    }
339
+    obj.room = room;
302
 
340
 
303
     return obj;
341
     return obj;
304
 }
342
 }

Loading…
Cancel
Save