Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat: Caches is secure room checks.

damenchoc6463196577c
diff --git a/react/features/base/util/isInsecureRoomName.ts b/react/features/base/util/isInsecureRoomName.ts
index b73a39865e..cec71f4dd5 100644
--- a/react/features/base/util/isInsecureRoomName.ts
+++ b/react/features/base/util/isInsecureRoomName.ts
@@ -5,6 +5,8 @@ import zxcvbn from 'zxcvbn';
// The null UUID.
const NIL_UUID = parseUUID(NIL);
+const _zxcvbnCache = new Map();
+
/**
* Checks if the given string is a valid UUID or not.
*
@@ -23,6 +25,24 @@ function isValidUUID(str: string) {
return !_.isEqual(uuid, NIL_UUID);
}
+/**
+ * Checks a room name and caches the result.
+ *
+ * @param {string} roomName - The room name.
+ * @returns {Object}
+ */
+function _checkRoomName(roomName = '') {
+ if (_zxcvbnCache.has(roomName)) {
+ return _zxcvbnCache.get(roomName);
+ }
+
+ const result = zxcvbn(roomName);
+
+ _zxcvbnCache.set(roomName, result);
+
+ return result;
+}
+
/**
* Returns true if the room name is considered a weak (insecure) one.
*
@@ -30,5 +50,7 @@ function isValidUUID(str: string) {
* @returns {boolean}
*/
export default function isInsecureRoomName(roomName = ''): boolean {
- return !isValidUUID(roomName) && zxcvbn(roomName).score < 3;
+
+ // room names longer than 200 chars we consider secure
+ return !isValidUUID(roomName) && (roomName.length < 200 && _checkRoomName(roomName).score < 3);
}