console-feed icon indicating copy to clipboard operation
console-feed copied to clipboard

Code breaks for objects created with Object.create(null)

Open vivek12345 opened this issue 6 years ago • 3 comments

When an object is created using Object.create(null) it does not contain properties that are inherited from Object for example hasOwnProperty or __proto__

Inside EncodingTransformer.prototype._handlePlainObject this causes an issue where in we depend on hasOwnProperty and also on __proto__. https://github.com/samdenty/console-feed/blob/master/src/Transform/replicator/index.ts#L98

This becomes an issue when someone is using query-string npm package https://www.npmjs.com/package/query-string This packages parse method creates a parsed object with Object.create(null);

I think we will have to place in a check for the existence of these properties on an object and only then handle them correctly.

@samdenty If it's alright then I would like to pick up this issue and propose a solution around the same.

vivek12345 avatar Nov 24 '18 16:11 vivek12345

replicator/index.ts is forked from https://www.npmjs.com/package/replicator, probably best to send a pr there and merge back

samdenty avatar Nov 24 '18 16:11 samdenty

Understood. Thank you @samdenty . I will send a PR on replicator.

vivek12345 avatar Nov 24 '18 17:11 vivek12345

Created a PR to fix the same. https://github.com/inikulin/replicator/pull/5

vivek12345 avatar Nov 24 '18 17:11 vivek12345