DataConnector table keys collide with object prototypes and empty keys
Expected behaviour
Every configured dataTables[].key string identifies its own table, including an empty string or a name inherited from Object.prototype. Calling getTable(key) should retrieve that table.
Actual behaviour
dataTables is an ordinary object and getTable uses a truthiness check. A __proto__ assignment changes the registry prototype instead of creating an own table entry, toString collides with an inherited member, and getTable('') falls back to the first table instead of performing the requested keyed lookup. Empty keys also advance the numeric fallback index because they are treated as absent.
Live demo with steps to reproduce
const connector = new DataConnector.types.CSV({
dataTables: [
{ key: '' },
{ key: '__proto__' },
{ key: 'toString' }
]
});
console.log(Object.keys(connector.dataTables));
console.log(connector.getTable('__proto__'));
console.log(connector.getTable('toString'));The registry does not contain all three own keys, and prototype-named lookups do not reliably return DataTable instances.
Product version
Highcharts master 48b5b3e99a0fa9aae9a357165a5a916f504afeca / 13.0.2
Affected browser(s)
All JavaScript environments.
Source: highcharts/highcharts