make returning plain objects and allowing prototype overwriting properties optional#98
make returning plain objects and allowing prototype overwriting properties optional#98
Conversation
|
To me, this seems to make the situation potentially worse, especially for user-confusion, because of the following not being the same: Can there be an option to use the default prototype and just overwrite properties, even if it's something you have to opt into? |
|
lol, please ignore my above comment, as it was technically only based off reading the source code. I see there is |
|
|
|
So I had made that comment in haste :) Let me really look through it to see what real comments I have :) |
|
Looks fine to me. Can't make everyone happy and I really don't care about prototype names in payload. This is JS. You are fucked anyway you look at it. |
|
Ok, so this PR seems fine in general. My only real comment is that I don't think the global environment should affect the functionality of the library: JSON.parse and the built-in query string does not have this issue, though: |
|
That would be resolved by exchanging |
|
Ok, changed this around so instead of optionally adding a prefix to properties that would overwrite the object prototype it instead optionally lets you shoot yourself in the foot, just like JSON.parse. It's off by default, but it's there. |
make returning plain objects and allowing prototype overwriting properties optional
|
This is only breaking when using |
|
this reverts the breaking change made in 3.x, so it's in itself another breaking change, though odds are if you don't use any of the prototype stuff on parsed results you'll never notice. |
|
ok, thanks for the explanation |
There was a problem hiding this comment.
Might be worth to explicitly note this is a security risk.
this is a short term solution before 5.0.0 which will change everything. Essentially the default behavior will match the 2.x releases, with the difference that you may set the
plainObjectsoption totrueto get the behavior from the 3.x releases.If you don't want plain objects but also don't want to lose keys that would overwrite prototype properties, you can set the
prefixPrototypesoption totrueand those keys will be prefixed with an underscore'_'and passed along. It's not perfect, but at least the keys aren't silently ignored.Would appreciate your feedback on this one @hueniverse @dougwilson