Handle corrupted values in input preferences

Bug: T246370
Change-Id: I13c730a6d584ad2f73807e11d5ceadfcb16a6040
This commit is contained in:
Niklas Laxström
2021-01-19 09:43:44 +01:00
committed by Nikerabbit
parent 207c5e6a9e
commit 4fc7bc9200

View File

@@ -84,6 +84,19 @@
load: function () {
this.registry = inputPreferences.get( 'ime' ) || this.registry;
// Some validation in case the stored preferences are corrupt
if ( typeof this.registry.language !== 'string' ) {
this.registry.language = null;
}
if ( !Array.isArray( this.registry.previousLanguages ) ) {
this.registry.previousLanguages = [];
}
if ( !Array.isArray( this.registry.previousInputMethods ) ) {
this.registry.previousInputMethods = [];
}
if ( !$.isPlainObject( this.registry.imes ) ) {
this.registry.imes = {};
}
},
disable: function () {