Browse Source

fix: Normalize the tenant part of the URL. (#9577)

This PR normalises the tenant part of the URL. For example, the following URL

    https://jitsi-meet.example.com/something@example.com/something@example.com

is converted to

    https://jitsi-meet.example.com/somethingexample.com/somethingexample.com

whereas before it was converted to

    https://jitsi-meet.example.com/something@example.com/somethingexample.com

i.e. the tenant part was not normalised
master
George Politis 4 years ago
parent
commit
75edfc1fab
No account linked to committer's email address
1 changed files with 14 additions and 23 deletions
  1. 14
    23
      react/features/base/util/uri.js

+ 14
- 23
react/features/base/util/uri.js View File

45
 export const URI_PROTOCOL_PATTERN = '^([a-z][a-z0-9\\.\\+-]*:)';
45
 export const URI_PROTOCOL_PATTERN = '^([a-z][a-z0-9\\.\\+-]*:)';
46
 
46
 
47
 /**
47
 /**
48
- * Excludes/removes certain characters from a specific room (name) which are
49
- * incompatible with Jitsi Meet on the client and/or server sides.
48
+ * Excludes/removes certain characters from a specific path part which are
49
+ * incompatible with Jitsi Meet on the client and/or server sides. The main
50
+ * use case for this method is to clean up the room name and the tenant.
50
  *
51
  *
51
- * @param {?string} room - The room (name) to fix.
52
+ * @param {?string} pathPart - The path part to fix.
52
  * @private
53
  * @private
53
  * @returns {?string}
54
  * @returns {?string}
54
  */
55
  */
55
-function _fixRoom(room: ?string) {
56
-    return room
57
-        ? room.replace(new RegExp(_ROOM_EXCLUDE_PATTERN, 'g'), '')
58
-        : room;
56
+function _fixPathPart(pathPart: ?string) {
57
+    return pathPart
58
+        ? pathPart.replace(new RegExp(_ROOM_EXCLUDE_PATTERN, 'g'), '')
59
+        : pathPart;
59
 }
60
 }
60
 
61
 
61
 /**
62
 /**
335
 
336
 
336
     const obj = parseStandardURIString(_fixURIStringScheme(uri));
337
     const obj = parseStandardURIString(_fixURIStringScheme(uri));
337
 
338
 
339
+    // XXX While the components/segments of pathname are URI encoded, Jitsi Meet
340
+    // on the client and/or server sides still don't support certain characters.
341
+    obj.pathname = obj.pathname.split('/').map(pathPart => _fixPathPart(pathPart))
342
+        .join('/');
343
+
338
     // Add the properties that are specific to a Jitsi Meet resource (location)
344
     // Add the properties that are specific to a Jitsi Meet resource (location)
339
     // such as contextRoot, room:
345
     // such as contextRoot, room:
340
 
346
 
344
     // The room (name) is the last component/segment of pathname.
350
     // The room (name) is the last component/segment of pathname.
345
     const { pathname } = obj;
351
     const { pathname } = obj;
346
 
352
 
347
-    // XXX While the components/segments of pathname are URI encoded, Jitsi Meet
348
-    // on the client and/or server sides still don't support certain characters.
349
     const contextRootEndIndex = pathname.lastIndexOf('/');
353
     const contextRootEndIndex = pathname.lastIndexOf('/');
350
-    let room = pathname.substring(contextRootEndIndex + 1) || undefined;
351
-
352
-    if (room) {
353
-        const fixedRoom = _fixRoom(room);
354
-
355
-        if (fixedRoom !== room) {
356
-            room = fixedRoom;
357
 
354
 
358
-            // XXX Drive fixedRoom into pathname (because room is derived from
359
-            // pathname).
360
-            obj.pathname
361
-                = pathname.substring(0, contextRootEndIndex + 1) + (room || '');
362
-        }
363
-    }
364
-    obj.room = room;
355
+    obj.room = pathname.substring(contextRootEndIndex + 1) || undefined;
365
 
356
 
366
     if (contextRootEndIndex > 1) {
357
     if (contextRootEndIndex > 1) {
367
         // The part of the pathname from the beginning to the room name is the tenant.
358
         // The part of the pathname from the beginning to the room name is the tenant.

Loading…
Cancel
Save