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

Some shims don’t guard against Object.prototype modifications #175

Closed
mathiasbynens opened this issue Dec 18, 2013 · 2 comments · Fixed by #177
Closed

Some shims don’t guard against Object.prototype modifications #175

mathiasbynens opened this issue Dec 18, 2013 · 2 comments · Fixed by #177
Assignees

Comments

@mathiasbynens
Copy link
Contributor

Add this to the tests:

Object.prototype[1] = 42; // try to break `arguments[1]`
Object.prototype[2] = 'lol'; // try to break `arguments[2]`

Functions and methods that might have this issue:

  • Array: from, fill, find, findIndex
  • String: startsWith, endsWith, contains
@paulmillr
Copy link
Owner

Is it a real concern or hasOwnProperty usage is in the spec?

@mathiasbynens
Copy link
Contributor Author

The spec for e.g. String#startsWith says:

Step 7. Let pos be ToInteger(position). (If position is undefined, this step produces the value 0).

Luckily, there’s no need to use hasOwnProperty to detect if a secondary argument was passed or not.

I had the same problem with my polyfill. Here’s the fix: mathiasbynens/String.prototype.startsWith@978e0c2

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

Successfully merging a pull request may close this issue.

3 participants