From 8d25952dbbacdcf139b46977199491c449235768 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 18 Nov 2019 14:17:31 -0700 Subject: [PATCH 1/2] Add a bit more safety around breadcrumbs Fixes https://github.com/vector-im/riot-web/issues/11420 --- src/settings/handlers/AccountSettingsHandler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/settings/handlers/AccountSettingsHandler.js b/src/settings/handlers/AccountSettingsHandler.js index f738bf7971..9c39d98990 100644 --- a/src/settings/handlers/AccountSettingsHandler.js +++ b/src/settings/handlers/AccountSettingsHandler.js @@ -126,6 +126,7 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa if (!content || !content['recent_rooms']) { content = this._getSettings(BREADCRUMBS_LEGACY_EVENT_TYPE); } + if (!content) content = {}; // If we still don't have content, make some content['recent_rooms'] = newValue; return MatrixClientPeg.get().setAccountData(BREADCRUMBS_EVENT_TYPE, content); @@ -167,7 +168,7 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa // This seems fishy - try and get the event for the new rooms const newType = this._getSettings(BREADCRUMBS_EVENT_TYPE); if (newType) val = newType['recent_rooms']; - else val = event.getContent()['rooms']; + else val = event.getContent()['rooms'] || []; } else if (event.getType() === BREADCRUMBS_EVENT_TYPE) { val = event.getContent()['recent_rooms']; } else { From 2f89f284965951013e8716df89aae5b8b622349f Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 18 Nov 2019 14:25:04 -0700 Subject: [PATCH 2/2] Remove extraneous paranoia The value is nullchecked later on. --- src/settings/handlers/AccountSettingsHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings/handlers/AccountSettingsHandler.js b/src/settings/handlers/AccountSettingsHandler.js index 9c39d98990..7b05ad0c1b 100644 --- a/src/settings/handlers/AccountSettingsHandler.js +++ b/src/settings/handlers/AccountSettingsHandler.js @@ -168,7 +168,7 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa // This seems fishy - try and get the event for the new rooms const newType = this._getSettings(BREADCRUMBS_EVENT_TYPE); if (newType) val = newType['recent_rooms']; - else val = event.getContent()['rooms'] || []; + else val = event.getContent()['rooms']; } else if (event.getType() === BREADCRUMBS_EVENT_TYPE) { val = event.getContent()['recent_rooms']; } else {