From e8b462cc310092a0db703fe56a16d697d4c62f92 Mon Sep 17 00:00:00 2001 From: Ishan Sharma Date: Sat, 25 Sep 2021 02:04:56 +0530 Subject: [PATCH] fix: Added alert for bad encryption key (#3998) --- src/excalidraw-app/data/index.ts | 4 ++++ src/locales/en.json | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/excalidraw-app/data/index.ts b/src/excalidraw-app/data/index.ts index 14ea6ba0..a470f1f9 100644 --- a/src/excalidraw-app/data/index.ts +++ b/src/excalidraw-app/data/index.ts @@ -137,6 +137,10 @@ export const decryptAESGEM = async ( export const getCollaborationLinkData = (link: string) => { const hash = new URL(link).hash; const match = hash.match(/^#room=([a-zA-Z0-9_-]+),([a-zA-Z0-9_-]+)$/); + if (match && match[2].length !== 22) { + window.alert(t("alerts.invalidEncryptionKey")); + return null; + } return match ? { roomId: match[1], roomKey: match[2] } : null; }; diff --git a/src/locales/en.json b/src/locales/en.json index 1df232cc..17ec527a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -157,7 +157,8 @@ "imageDoesNotContainScene": "Importing images isn't supported at the moment.\n\nDid you want to import a scene? This image does not seem to contain any scene data. Have you enabled this during export?", "cannotRestoreFromImage": "Scene couldn't be restored from this image file", "invalidSceneUrl": "Couldn't import scene from the supplied URL. It's either malformed, or doesn't contain valid Excalidraw JSON data.", - "resetLibrary": "This will clear your library. Are you sure?" + "resetLibrary": "This will clear your library. Are you sure?", + "invalidEncryptionKey": "Encryption key must be of 22 characters. Live collaboration is disabled." }, "toolBar": { "selection": "Selection",