Skip to content

Commit 889eb16

Browse files
committed
Block bad keys in _mergerIf
1 parent 20e10a8 commit 889eb16

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/helpers/helpers.core.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
function isValidKey(key) {
4+
return ['__proto__', 'prototype', 'constructor'].indexOf(key) === -1;
5+
}
6+
37
/**
48
* @namespace Chart.helpers
59
*/
@@ -196,7 +200,7 @@ var helpers = {
196200
* @private
197201
*/
198202
_merger: function(key, target, source, options) {
199-
if (['__proto__', 'prototype', 'constructor'].indexOf(key) !== -1) {
203+
if (!isValidKey(key)) {
200204
// We want to ensure we do not copy prototypes over
201205
// as this can pollute global namespaces
202206
return;
@@ -217,6 +221,12 @@ var helpers = {
217221
* @private
218222
*/
219223
_mergerIf: function(key, target, source) {
224+
if (!isValidKey(key)) {
225+
// We want to ensure we do not copy prototypes over
226+
// as this can pollute global namespaces
227+
return;
228+
}
229+
220230
var tval = target[key];
221231
var sval = source[key];
222232

0 commit comments

Comments
 (0)