Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Block bad keys in _mergerIf
  • Loading branch information
etimberg committed Oct 18, 2020
commit 889eb161a440a0268b859c34e9c12f9a12446e52
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