From 178550d4b7234efe85ed2c7b34dd6acc1a179e10 Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel <lloyd@hilaiel.com> Date: Thu, 23 Jun 2011 10:30:20 -0600 Subject: [PATCH] handle case where localstorage gets b0rked by resetting it when required --- browserid/static/dialog/main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/browserid/static/dialog/main.js b/browserid/static/dialog/main.js index e11110697..e17f0ce41 100644 --- a/browserid/static/dialog/main.js +++ b/browserid/static/dialog/main.js @@ -49,8 +49,14 @@ { var emails = {}; if (window.localStorage.emails) { - emails = JSON.parse(window.localStorage.emails); + try { + emails = JSON.parse(window.localStorage.emails); + } catch(e) { + // if somehow window.localStorage.emails is populated with bogus + // JSON, we'll just purge it. + } } + if (emails === null || typeof emails !== 'object') emails = {}; emails[email] = { created: new Date(), -- GitLab