-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Issues regarding the use of __proto__ #3103
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
Comments
It's the |
Can you provide the code in which you are seeing that property show up in a loop though the properties? |
I temporarily added this to my code this morning at the very beginning where I log incoming requests (I removed the logging code), just to verify that it wasn't me that was putting it in there somehow (I never use
And it shows that the query object on
So, if you want to loop through the keys in query to see what query parameters are available, things get a little strange. :) Hope this helps clarifying the issue. Julian |
And, I forgot to add this:
That's from the current Julian |
We never touch the proto property on req.query are you sure that does not return true for any object in JavaScript in general? |
Basically I guess I'm not clear on what is ask really is, especially since you are referring to req.query, which comes from whatever the parsing modules are doing, so I'm not sure if a PR here could alter that behavior. Perhaps if you put together a PR that could help understand what the suggested fix is, as I'm still not clear on what exactly is being reported here. |
Upon further investigation, it would appear that the query object does not have the Sorry to have taken up your time. Should you wish to remove the Thanks for the prompt attention, |
Gotcha. If the issue is now simply about using it as a general thing vs there actually being a real issue, there are multiple issues you can read for past discussions like #2613 and the issues/PRs it links to. Basically you cannot replace it with Object.create, as we are altering objects we are creating and you cannot replace it with Object.defineProperty, because it will not trigger the setter on the previous property, which is the entire point of setting it. We could replace them with Object.setPeototypeOf when we only support Node.js versions that actually have that available, which is not on the roadmap. |
Any chance that the use of
__proto__
can be changed? Looping through some objects created in express needs a check for__proto__
which is, at least, violates the principle of least astonishment. And then there's this:Form MDN:
I understand that using
Object.create()
, or outright removing__proto__
, would probably be too much of a change, how about a compromise:Instead of
use
There are many ways to avoid using the deprecated and detrimental technique and it would be nice to shed its use, especially with a new version coming up. Anyway, just a suggestion. If there is any interest in making this change, I wouldn't mind doing a pull request on it.
Julian
The text was updated successfully, but these errors were encountered: