From 75edfc1fab56b53a5e9a4df03537b7d9c7f5983b Mon Sep 17 00:00:00 2001 From: George Politis Date: Wed, 21 Jul 2021 18:48:08 +0100 Subject: [PATCH] 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 --- react/features/base/util/uri.js | 37 +++++++++++++-------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/react/features/base/util/uri.js b/react/features/base/util/uri.js index dae116a04..9ab604b17 100644 --- a/react/features/base/util/uri.js +++ b/react/features/base/util/uri.js @@ -45,17 +45,18 @@ const _URI_PATH_PATTERN = '([^?#]*)'; export const URI_PROTOCOL_PATTERN = '^([a-z][a-z0-9\\.\\+-]*:)'; /** - * Excludes/removes certain characters from a specific room (name) which are - * incompatible with Jitsi Meet on the client and/or server sides. + * Excludes/removes certain characters from a specific path part which are + * incompatible with Jitsi Meet on the client and/or server sides. The main + * use case for this method is to clean up the room name and the tenant. * - * @param {?string} room - The room (name) to fix. + * @param {?string} pathPart - The path part to fix. * @private * @returns {?string} */ -function _fixRoom(room: ?string) { - return room - ? room.replace(new RegExp(_ROOM_EXCLUDE_PATTERN, 'g'), '') - : room; +function _fixPathPart(pathPart: ?string) { + return pathPart + ? pathPart.replace(new RegExp(_ROOM_EXCLUDE_PATTERN, 'g'), '') + : pathPart; } /** @@ -335,6 +336,11 @@ export function parseURIString(uri: ?string) { const obj = parseStandardURIString(_fixURIStringScheme(uri)); + // XXX While the components/segments of pathname are URI encoded, Jitsi Meet + // on the client and/or server sides still don't support certain characters. + obj.pathname = obj.pathname.split('/').map(pathPart => _fixPathPart(pathPart)) + .join('/'); + // Add the properties that are specific to a Jitsi Meet resource (location) // such as contextRoot, room: @@ -344,24 +350,9 @@ export function parseURIString(uri: ?string) { // The room (name) is the last component/segment of pathname. const { pathname } = obj; - // XXX While the components/segments of pathname are URI encoded, Jitsi Meet - // on the client and/or server sides still don't support certain characters. const contextRootEndIndex = pathname.lastIndexOf('/'); - let room = pathname.substring(contextRootEndIndex + 1) || undefined; - if (room) { - const fixedRoom = _fixRoom(room); - - if (fixedRoom !== room) { - room = fixedRoom; - - // XXX Drive fixedRoom into pathname (because room is derived from - // pathname). - obj.pathname - = pathname.substring(0, contextRootEndIndex + 1) + (room || ''); - } - } - obj.room = room; + obj.room = pathname.substring(contextRootEndIndex + 1) || undefined; if (contextRootEndIndex > 1) { // The part of the pathname from the beginning to the room name is the tenant.