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

marshal accepts getters that return functions #2436

Closed
warner opened this issue Feb 16, 2021 · 0 comments
Closed

marshal accepts getters that return functions #2436

warner opened this issue Feb 16, 2021 · 0 comments
Assignees
Labels
bug Something isn't working marshal package: marshal

Comments

@warner
Copy link
Member

warner commented Feb 16, 2021

Describe the bug

marshal is pretty tolerant about what "pass-by-reference" means: it allows properties to be named with strings or Symbols, and it allows both enumerable and non-enumerable properties. The only rule is that the property values must be functions.

It looks like it was a little too lenient, and it accepts properties with getters, as long as those getters return a function. The problem is that the getter might return a function today, but not tomorrow.

The requirement is it tighten the rules by only allowing properties which are defined by values, and rejecting ones defined with a getter.

I've got a patch which improves the tests to cover this case, and reject it.

@warner warner added bug Something isn't working marshal package: marshal labels Feb 16, 2021
@warner warner self-assigned this Feb 16, 2021
warner added a commit that referenced this issue Feb 16, 2021
…ction

The prohibit-accessors check was improved by using `!('get' in descs[key])`.
This should catch properties with a setter but not a getter, which will have
a descriptor with `get: undefined`. Although this happens to be caught
elsewhere, (because such a property reads as a non-function, triggering the
"cannot serialize objects with non-methods" clause.

closes #2436
@warner warner closed this as completed in b9368b6 Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working marshal package: marshal
Projects
None yet
Development

No branches or pull requests

1 participant