From 8ffe14881e94b0b7b8fc05ce2a650cc8f2c425cf Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 5 Dec 2016 18:33:38 +0000 Subject: [PATCH 1/6] Don't throw an exception entering settings page if end to end encryption is disabled (eg. if you're a guest and the server is too old to support e2e for guests). --- src/components/structures/UserSettings.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index b82f2f5958..c15f58013e 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -338,7 +338,16 @@ module.exports = React.createClass({ }, _renderCryptoInfo: function() { - var client = MatrixClientPeg.get(); + const client = MatrixClientPeg.get(); + if (!client.isCryptoEnabled()) { + return
+

Cryptography

+
+ End-to-end encryption is disabled +
+
; + } + var deviceId = client.deviceId; var identityKey = client.getDeviceEd25519Key() || ""; From 6777e07a41f69697df9e495fb752343daa3b3530 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 5 Dec 2016 20:03:43 +0000 Subject: [PATCH 2/6] Remove device name from crypto section As it was getting it by assuming our device was the first one, which is just not a valid assumption. --- src/components/structures/UserSettings.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index c15f58013e..49674957bc 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -339,25 +339,14 @@ module.exports = React.createClass({ _renderCryptoInfo: function() { const client = MatrixClientPeg.get(); - if (!client.isCryptoEnabled()) { - return
-

Cryptography

-
- End-to-end encryption is disabled -
-
; - } + const deviceId = client.deviceId; + const identityKey = client.getDeviceEd25519Key() || ""; - var deviceId = client.deviceId; - var identityKey = client.getDeviceEd25519Key() || ""; - - var myDevice = client.getStoredDevicesForUser(MatrixClientPeg.get().credentials.userId)[0]; return (

Cryptography

    -
  • { myDevice.getDisplayName() }
  • {deviceId}
  • {identityKey}
From 28e663dd48dde71a717a12dc61fc08e0c47ffc01 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 6 Dec 2016 13:27:36 +0000 Subject: [PATCH 3/6] Pass the room object into displayNotification It needs it to do the view_room if the notification is clicked. --- src/BasePlatform.js | 2 +- src/Notifier.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index 897a1a2dc8..b8c400c6e3 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -63,7 +63,7 @@ export default class BasePlatform { requestNotificationPermission() : Promise { } - displayNotification(title: string, msg: string, avatarUrl: string) { + displayNotification(title: string, msg: string, avatarUrl: string, room: Object) { } /** diff --git a/src/Notifier.js b/src/Notifier.js index b9260a046d..a58fc0132f 100644 --- a/src/Notifier.js +++ b/src/Notifier.js @@ -73,7 +73,7 @@ var Notifier = { ev.sender, 40, 40, 'crop' ) : null; - const notif = plaf.displayNotification(title, msg, avatarUrl); + const notif = plaf.displayNotification(title, msg, avatarUrl, room); // if displayNotification returns non-null, the platform supports // clearing notifications later, so keep track of this. From ef1cb9530fd6b1c94638d4fd3239afee33f58451 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 6 Dec 2016 14:30:21 +0000 Subject: [PATCH 4/6] Allow integration UI URLs with paths The postMessage API assumed that event origins contained paths of their window origins, but they do not (https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage). This changes the origin check such that the integrations UI URL must start with the event origin. --- src/ScalarMessaging.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index db2baa433b..75062daaa2 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -292,12 +292,15 @@ const onMessage = function(event) { event.origin = event.originalEvent.origin; } - // check it is from the integrations UI URL (remove trailing spaces) + // Check that the integrations UI URL starts with the origin of the event + // This means the URL could contain a path (like /develop) and still be used + // to validate event origins, which do not specify paths. + // (See https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) + // + // All strings start with the empty string, so for sanity return if the length + // of the event origin is 0. let url = SdkConfig.get().integrations_ui_url; - if (url.endsWith("/")) { - url = url.substr(0, url.length - 1); - } - if (url !== event.origin) { + if (event.origin.length === 0 || !url.startsWith(event.origin)) { return; // don't log this - debugging APIs like to spam postMessage which floods the log otherwise } From a3ab59832e647a45747cc9010ce3c1538a0f206a Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 6 Dec 2016 14:40:09 +0000 Subject: [PATCH 5/6] Give the search box field a name Should fix https://github.com/vector-im/riot-web/issues/2462 --- src/components/views/elements/DirectorySearchBox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/elements/DirectorySearchBox.js b/src/components/views/elements/DirectorySearchBox.js index a453dfb62a..3ea0d16336 100644 --- a/src/components/views/elements/DirectorySearchBox.js +++ b/src/components/views/elements/DirectorySearchBox.js @@ -89,7 +89,7 @@ export default class DirectorySearchBox extends React.Component { return
- Date: Tue, 6 Dec 2016 14:59:10 +0000 Subject: [PATCH 6/6] Fix exception when clearing room dir search Needed more isMounted checks after promises return. --- src/components/structures/ScrollPanel.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/structures/ScrollPanel.js b/src/components/structures/ScrollPanel.js index 31ac59c730..a9e16d364c 100644 --- a/src/components/structures/ScrollPanel.js +++ b/src/components/structures/ScrollPanel.js @@ -402,6 +402,9 @@ module.exports = React.createClass({ q.finally(fillPromise, () => { this._pendingFillRequests[dir] = false; }).then((hasMoreResults) => { + if (this.unmounted) { + return; + } // Unpaginate once filling is complete this._checkUnfillState(!backwards);