Kaynağa Gözat

fix: utf-8 room name case sensitivity

master
Bettenbuk Zoltan 5 yıl önce
ebeveyn
işleme
13d78d6b49

+ 2
- 1
react/features/app/actions.js Dosyayı Görüntüle

@@ -15,6 +15,7 @@ import { connect, disconnect, setLocationURL } from '../base/connection';
15 15
 import { loadConfig } from '../base/lib-jitsi-meet';
16 16
 import { createDesiredLocalTracks } from '../base/tracks';
17 17
 import {
18
+    getBackendSafeRoomName,
18 19
     getLocationContextRoot,
19 20
     parseURIString,
20 21
     toURLString
@@ -85,7 +86,7 @@ export function appNavigate(uri: ?string) {
85 86
         let url = `${baseURL}config.js`;
86 87
 
87 88
         // XXX In order to support multiple shards, tell the room to the deployment.
88
-        room && (url += `?room=${room.toLowerCase()}`);
89
+        room && (url += `?room=${getBackendSafeRoomName(room)}`);
89 90
 
90 91
         let config;
91 92
 

+ 5
- 3
react/features/base/conference/actions.js Dosyayı Görüntüle

@@ -23,7 +23,10 @@ import {
23 23
     participantUpdated
24 24
 } from '../participants';
25 25
 import { getLocalTracks, trackAdded, trackRemoved } from '../tracks';
26
-import { getJitsiMeetGlobalNS } from '../util';
26
+import {
27
+    getBackendSafeRoomName,
28
+    getJitsiMeetGlobalNS
29
+} from '../util';
27 30
 
28 31
 import {
29 32
     AUTH_STATUS_CHANGED,
@@ -388,8 +391,7 @@ export function createConference() {
388 391
         const conference
389 392
             = connection.initJitsiConference(
390 393
 
391
-                // XXX Lib-jitsi-meet does not accept uppercase letters.
392
-                room.toLowerCase(), {
394
+                getBackendSafeRoomName(room), {
393 395
                     ...state['features/base/config'],
394 396
                     applicationName: getName(),
395 397
                     getWiFiStatsMethod: getJitsiMeetGlobalNS().getWiFiStats,

+ 4
- 4
react/features/base/config/getRoomName.js Dosyayı Görüntüle

@@ -1,5 +1,7 @@
1 1
 /* @flow */
2 2
 
3
+import { getBackendSafeRoomName } from '../util';
4
+
3 5
 declare var config: Object;
4 6
 
5 7
 /**
@@ -20,10 +22,8 @@ export default function getRoomName(): ?string {
20 22
         // URL maps to the room (name). It currently assumes a deployment in
21 23
         // which the last non-directory component of the path (name) is the
22 24
         // room.
23
-        roomName
24
-            = path.substring(path.lastIndexOf('/') + 1).toLowerCase()
25
-                || undefined;
25
+        roomName = path.substring(path.lastIndexOf('/') + 1) || undefined;
26 26
     }
27 27
 
28
-    return roomName;
28
+    return getBackendSafeRoomName(roomName);
29 29
 }

+ 5
- 5
react/features/base/connection/actions.native.js Dosyayı Görüntüle

@@ -9,7 +9,10 @@ import {
9 9
     getCurrentConference
10 10
 } from '../conference';
11 11
 import JitsiMeetJS, { JitsiConnectionEvents } from '../lib-jitsi-meet';
12
-import { parseURIString } from '../util';
12
+import {
13
+    getBackendSafeRoomName,
14
+    parseURIString
15
+} from '../util';
13 16
 
14 17
 import {
15 18
     CONNECTION_DISCONNECTED,
@@ -307,10 +310,7 @@ function _constructOptions(state) {
307 310
         // Append room to the URL's search.
308 311
         const { room } = state['features/base/conference'];
309 312
 
310
-        // XXX The Jitsi Meet deployments require the room argument to be in
311
-        // lower case at the time of this writing but, unfortunately, they do
312
-        // not ignore case themselves.
313
-        room && (bosh += `?room=${room.toLowerCase()}`);
313
+        room && (bosh += `?room=${getBackendSafeRoomName(room)}`);
314 314
 
315 315
         options.bosh = bosh;
316 316
     }

+ 2
- 2
react/features/base/connection/actions.web.js Dosyayı Görüntüle

@@ -6,6 +6,7 @@ declare var APP: Object;
6 6
 declare var config: Object;
7 7
 
8 8
 import { configureInitialDevices } from '../devices';
9
+import { getBackendSafeRoomName } from '../util';
9 10
 
10 11
 export {
11 12
     connectionEstablished,
@@ -21,8 +22,7 @@ import logger from './logger';
21 22
  */
22 23
 export function connect() {
23 24
     return (dispatch: Dispatch<any>, getState: Function) => {
24
-        // XXX Lib-jitsi-meet does not accept uppercase letters.
25
-        const room = getState()['features/base/conference'].room.toLowerCase();
25
+        const room = getBackendSafeRoomName(getState()['features/base/conference'].room);
26 26
 
27 27
         // XXX For web based version we use conference initialization logic
28 28
         // from the old app (at the moment of writing).

+ 41
- 0
react/features/base/util/uri.js Dosyayı Görüntüle

@@ -96,6 +96,47 @@ function _fixURIStringScheme(uri: string) {
96 96
     return uri;
97 97
 }
98 98
 
99
+/**
100
+ * Converts a room name to a backend-safe format. Properly lowercased and url encoded.
101
+ *
102
+ * @param {string?} room - The room name to convert.
103
+ * @returns {string?}
104
+ */
105
+export function getBackendSafeRoomName(room: ?string): ?string {
106
+    if (!room) {
107
+        return room;
108
+    }
109
+
110
+    /* eslint-disable no-param-reassign */
111
+    try {
112
+        // We do not know if we get an already encoded string at this point
113
+        // as different platforms do it differently, but we need a decoded one
114
+        // for sure. However since decoding a non-encoded string is a noop, we're safe
115
+        // doing it here.
116
+        room = decodeURIComponent(room);
117
+    } catch (e) {
118
+        // This can happen though if we get an unencoded string and it contains
119
+        // some characters that look like an encoded entity, but it's not.
120
+        // But in this case we're fine goin on...
121
+    }
122
+
123
+    // Normalize the character set
124
+    room = room.normalize('NFKC');
125
+
126
+    // Only decoded and normalized strings can be lowercased properly.
127
+    room = room.toLowerCase();
128
+
129
+    // But we still need to (re)encode it.
130
+    room = encodeURIComponent(room);
131
+    /* eslint-enable no-param-reassign */
132
+
133
+    // Unfortunately we still need to lowercase it, because encoding a string will
134
+    // add some uppercase characters, but some backend services
135
+    // expect it to be full lowercase. However lowercasing an encoded string
136
+    // doesn't change the string value.
137
+    return room.toLowerCase();
138
+}
139
+
99 140
 /**
100 141
  * Gets the (Web application) context root defined by a specific location (URI).
101 142
  *

+ 1
- 1
react/features/welcome/components/AbstractWelcomePage.js Dosyayı Görüntüle

@@ -192,7 +192,7 @@ export class AbstractWelcomePage extends Component<Props, *> {
192 192
             const onAppNavigateSettled
193 193
                 = () => this._mounted && this.setState({ joining: false });
194 194
 
195
-            this.props.dispatch(appNavigate(encodeURI(room)))
195
+            this.props.dispatch(appNavigate(room))
196 196
                 .then(onAppNavigateSettled, onAppNavigateSettled);
197 197
         }
198 198
     }

Loading…
İptal
Kaydet