Skip to content
Snippets Groups Projects
Commit 8737d6e2 authored by Lloyd Hilaiel's avatar Lloyd Hilaiel
Browse files

defend against garbage in localStorage

parent 238e83de
No related branches found
No related tags found
No related merge requests found
...@@ -330,7 +330,13 @@ BrowserID.Storage = (function() { ...@@ -330,7 +330,13 @@ BrowserID.Storage = (function() {
// this map helps us determine whether a specific email address belongs // this map helps us determine whether a specific email address belongs
// to a user who has already confirmed their ownership of a computer. // to a user who has already confirmed their ownership of a computer.
function updateEmailToUserIDMapping(userid, emails) { function updateEmailToUserIDMapping(userid, emails) {
var allInfo = JSON.parse(storage.emailToUserID || "{}"); var allInfo;
try {
allInfo = JSON.parse(storage.emailToUserID);
if (typeof allInfo != 'object' || allInfo === null) throw "bogus";
} catch(e) {
allInfo = {};
}
_.each(emails, function(email) { _.each(emails, function(email) {
allInfo[email] = userid; allInfo[email] = userid;
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment