From 882297b6d98f758b0be318580413304128f77dd1 Mon Sep 17 00:00:00 2001 From: Vladimir Kotikov Date: Thu, 25 Feb 2016 11:45:22 +0300 Subject: [PATCH] CB-10583 Protect plugin preferences from adding extra Array properties --- cordova-common/src/PluginInfo/PluginInfo.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/cordova-common/src/PluginInfo/PluginInfo.js b/cordova-common/src/PluginInfo/PluginInfo.js index 2554a3c2f..e1a1b3180 100644 --- a/cordova-common/src/PluginInfo/PluginInfo.js +++ b/cordova-common/src/PluginInfo/PluginInfo.js @@ -43,18 +43,14 @@ function PluginInfo(dirname) { // tag // Example: // Used to require a variable to be specified via --variable when installing the plugin. + // returns { key : default | null} self.getPreferences = getPreferences; function getPreferences(platform) { - var arprefs = _getTags(self._et, 'preference', platform, _parsePreference); - - var prefs= {}; - for(var i in arprefs) - { - var pref=arprefs[i]; - prefs[pref.preference]=pref.default; - } - // returns { key : default | null} - return prefs; + return _getTags(self._et, 'preference', platform, _parsePreference) + .reduce(function (preferences, pref) { + preferences[pref.preference] = pref.default; + return preferences; + }, {}); } function _parsePreference(prefTag) {