From 0a87baf99d2afd517f1a594d14372223d82459db Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Thu, 2 Sep 2021 20:30:12 +0200 Subject: [PATCH] Remove accidentally persisted log-level data This commit gets rid of log-level data in localStorage which in some extreme cases could fill up the entire localStorage making the app unusable Followup to https://github.com/matrix-org/matrix-js-sdk/pull/1880 --- src/vector/index.ts | 1 + src/vector/localstorage-fix.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 src/vector/localstorage-fix.ts diff --git a/src/vector/index.ts b/src/vector/index.ts index de68bf0a43..e23fc4b35a 100644 --- a/src/vector/index.ts +++ b/src/vector/index.ts @@ -33,6 +33,7 @@ require('katex/dist/katex.css'); * On production build it's going to be an empty module, so don't worry about that. */ require('./devcss'); +require('./localstorage-fix'); // These are things that can run before the skin loads - be careful not to reference the react-sdk though. import { parseQsFromFragment } from "./url_utils"; import './modernizr'; diff --git a/src/vector/localstorage-fix.ts b/src/vector/localstorage-fix.ts new file mode 100644 index 0000000000..d0ca05174f --- /dev/null +++ b/src/vector/localstorage-fix.ts @@ -0,0 +1,12 @@ +/** + * Because we've been saving a lot of additional logger data in the localStorage for no particular reason + * we need to, hopefully, unbrick user's devices by geting rid of unnecessary data. + * */ + +if (window.localStorage) { + Object.keys(window.localStorage).forEach(key => { + if (key.indexOf('loglevel:') === 0) { + window.localStorage.removeItem(key); + } + }); +}