Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vivek12345 opened this issue Nov 24, 2018 · 3 comments
Open

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

vivek12345 opened this issue Nov 24, 2018 · 3 comments

Comments

@vivek12345
Copy link

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 vivek12345 changed the title _handlePlainObject breaks for objects created with Object.create(null) Code breaks for objects created with Object.create(null) Nov 24, 2018
@samdenty
Copy link
Owner

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

@vivek12345
Copy link
Author

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

@vivek12345
Copy link
Author

Created a PR to fix the same.
inikulin/replicator#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants