Merge "Prevent JSON parsing errors"

This commit is contained in:
jenkins-bot
2014-02-11 08:27:23 +00:00
committed by Gerrit Code Review

View File

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