Prevent all strings from being parsed as JSON.

This commit is contained in:
Ajay Ramachandran
2020-02-08 20:15:49 -05:00
parent be3a4a4e91
commit 94af8ab301

View File

@@ -84,7 +84,6 @@ class SBMap<T, U> extends Map {
} }
} }
var Config: SBObject = { var Config: SBObject = {
/** /**
* Callback function when an option is updated * Callback function when an option is updated
@@ -151,10 +150,14 @@ function decodeStoredItem(id: string, data) {
// This is the old format for SBMap (a JSON string) // This is the old format for SBMap (a JSON string)
if (typeof data === "string") { if (typeof data === "string") {
try {
let str = JSON.parse(data); let str = JSON.parse(data);
if (Array.isArray(data)) { if (Array.isArray(data)) {
return new SBMap(id, str) return new SBMap(id, str);
}
} catch(e) {
// Continue normally (out of this if statement)
} }
} }