From 2b027b716f1bb43639fac2e46b663a6c92b74296 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 27 Nov 2018 14:23:28 -0700 Subject: [PATCH 1/2] Suppress CORS errors in the 'failed to join room' dialog This isn't pretty, but it does address https://github.com/vector-im/riot-web/issues/7526 Tested with Chrome and Firefox to ensure the message is stable enough to parse. --- src/i18n/strings/en_EN.json | 1 + src/stores/RoomViewStore.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 557ef62edf..c80cbe6c55 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -220,6 +220,7 @@ "Your browser does not support the required cryptography extensions": "Your browser does not support the required cryptography extensions", "Not a valid Riot keyfile": "Not a valid Riot keyfile", "Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?", + "There was an error joining the room": "There was an error joining the room", "Sorry, your homeserver is too old to participate in this room.": "Sorry, your homeserver is too old to participate in this room.", "Please contact your homeserver administrator.": "Please contact your homeserver administrator.", "Failed to join room": "Failed to join room", diff --git a/src/stores/RoomViewStore.js b/src/stores/RoomViewStore.js index f15925f480..5ddd84c07c 100644 --- a/src/stores/RoomViewStore.js +++ b/src/stores/RoomViewStore.js @@ -224,6 +224,9 @@ class RoomViewStore extends Store { err: err, }); let msg = err.message ? err.message : JSON.stringify(err); + if (msg && msg.startsWith("CORS request rejected")) { + msg = _t("There was an error joining the room"); + } if (err.errcode === 'M_INCOMPATIBLE_ROOM_VERSION') { msg =
{_t("Sorry, your homeserver is too old to participate in this room.")}
From 7e817f4aa90a739c4a15e9bb91f874651ee529f9 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 5 Dec 2018 11:29:53 -0700 Subject: [PATCH 2/2] Add a helpful comment --- src/stores/RoomViewStore.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/stores/RoomViewStore.js b/src/stores/RoomViewStore.js index 5ddd84c07c..9e048e5d8e 100644 --- a/src/stores/RoomViewStore.js +++ b/src/stores/RoomViewStore.js @@ -224,6 +224,8 @@ class RoomViewStore extends Store { err: err, }); let msg = err.message ? err.message : JSON.stringify(err); + // XXX: We are relying on the error message returned by browsers here. + // This isn't great, but it does generalize the error being shown to users. if (msg && msg.startsWith("CORS request rejected")) { msg = _t("There was an error joining the room"); }