Prevent JSON parsing errors

Bug: 61137
Change-Id: I2df6b6108bb7834b927205d3b6afa69354cecaf7
This commit is contained in:
Amir E. Aharoni
2014-02-10 15:25:37 +02:00
parent ab83208b60
commit 7627358fb4

View File

@@ -180,8 +180,15 @@
this.preferences = preferenceStore().get( this.preferenceName );
} else {
var options = mw.user.options.get( this.preferenceName );
this.preferences = JSON.parse( options );
// Try to parse JSON
try {
this.preferences = JSON.parse( options );
} catch ( e ) {
this.preferences = {};
}
}
this.preferences = this.preferences || {};
},