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

Cannot read property 'name' of undefined #258

Open
franciscolourenco opened this issue Oct 13, 2020 · 4 comments
Open

Cannot read property 'name' of undefined #258

franciscolourenco opened this issue Oct 13, 2020 · 4 comments

Comments

@franciscolourenco
Copy link

franciscolourenco commented Oct 13, 2020

Node querystring.parse method returns an object with null prototype for security reasons.

Passing that object to serialize() throws Cannot read property 'name' of undefined.

Would it be possible to stop depending on the object's prototype in order to fix this issue?

Thanks!

Related:

@philipp-tailor
Copy link

👍🏼 for this request.

Is the library still actively maintained?

@steelbrain
Copy link
Owner

Is the library still actively maintained?

Yes. The bug seems to be out of scope of the lib tho, you could just add an if/else statement in your own code to handle this

@franciscolourenco
Copy link
Author

@steelbrain A common way to parse url-encoded-form data is to use the native node querystring.parse() function. Since this is a node library it would probably be a good idea to be compatible with node generally speaking.

Is there anything which prevents php-serialize form using a more fail-proof method of identifying objects, like for instance:

typeof object === 'object' && object !== null

franciscolourenco added a commit to franciscolourenco/php-serialize that referenced this issue Apr 12, 2021
https://nodejs.org/api/querystring.html#querystring_querystring_parse_str_sep_eq_options

"The object returned by the querystring.parse() method does not prototypically inherit from the JavaScript Object. This means that typical Object methods such as obj.toString(), obj.hasOwnProperty(), and others are not defined and will not work."

fix steelbrain#258
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

3 participants