Prevent JSON parsing errors
Bug: 61137 Change-Id: I2df6b6108bb7834b927205d3b6afa69354cecaf7
This commit is contained in:
@@ -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 || {};
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user