Skip to content
Open
Changes from all commits
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
9 changes: 9 additions & 0 deletions src/core/core.defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import {applyScaleDefaults} from './core.scale.defaults.js';
export const overrides = Object.create(null);
export const descriptors = Object.create(null);


function isValidScopePath(key) {
return !key.split('.').some((part) => (
part === '__proto__' || part === 'prototype' || part === 'constructor'
));
}
Comment on lines +11 to +15
/**
* @param {object} node
* @param {string} key
Expand All @@ -16,6 +22,9 @@ function getScope(node, key) {
if (!key) {
return node;
}
if (!isValidScopePath(key)) {
throw new Error(`Invalid defaults scope: ${key}`);
}
Comment on lines +25 to +27
Comment on lines +25 to +27
const keys = key.split('.');
for (let i = 0, n = keys.length; i < n; ++i) {
const k = keys[i];
Expand Down