diff --git a/atom/browser/api/atom_api_system_preferences_mac.mm b/atom/browser/api/atom_api_system_preferences_mac.mm index b078db585d57..8f7ce7f144c5 100644 --- a/atom/browser/api/atom_api_system_preferences_mac.mm +++ b/atom/browser/api/atom_api_system_preferences_mac.mm @@ -152,13 +152,13 @@ void SystemPreferences::RegisterDefaults(mate::Arguments* args) { } else { @try { NSDictionary* dict = DictionaryValueToNSDictionary(value); - // for (id key in dict) { - // id value = [dict objectForKey:key]; - // if (value == nil) { - // printf("HELLO\n"); - // args->ThrowError("Invalid userDefault data provided"); - // } - // } + for (id key in dict) { + id value = [dict objectForKey:key]; + if ([value isKindOfClass:[NSNull class]] || value == nil) { + args->ThrowError("Invalid userDefault data provided"); + return; + } + } [[NSUserDefaults standardUserDefaults] registerDefaults:dict]; } @catch (NSException* exception) { args->ThrowError("Invalid userDefault data provided"); diff --git a/spec/api-system-preferences-spec.js b/spec/api-system-preferences-spec.js index 36902ffaf18f..96e52979fdd5 100644 --- a/spec/api-system-preferences-spec.js +++ b/spec/api-system-preferences-spec.js @@ -66,6 +66,7 @@ describe('systemPreferences module', () => { 1, null, new Date(), + { 'one': null } ] for (const badDefault of badDefaults) {