Skip to content

Commit

Permalink
Block bad keys in _mergerIf
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Oct 18, 2020
1 parent 20e10a8 commit 889eb16
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/helpers/helpers.core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

function isValidKey(key) {
return ['__proto__', 'prototype', 'constructor'].indexOf(key) === -1;
}

/**
* @namespace Chart.helpers
*/
Expand Down Expand Up @@ -196,7 +200,7 @@ var helpers = {
* @private
*/
_merger: function(key, target, source, options) {
if (['__proto__', 'prototype', 'constructor'].indexOf(key) !== -1) {
if (!isValidKey(key)) {
// We want to ensure we do not copy prototypes over
// as this can pollute global namespaces
return;
Expand All @@ -217,6 +221,12 @@ var helpers = {
* @private
*/
_mergerIf: function(key, target, source) {
if (!isValidKey(key)) {
// We want to ensure we do not copy prototypes over
// as this can pollute global namespaces
return;
}

var tval = target[key];
var sval = source[key];

Expand Down

0 comments on commit 889eb16

Please sign in to comment.