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

Comments

Projects
None yet
3 participants
@mathiasbynens
Contributor

mathiasbynens commented Dec 18, 2013

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

This comment has been minimized.

Show comment
Hide comment
@paulmillr

paulmillr Dec 18, 2013

Owner

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

Owner

paulmillr commented Dec 18, 2013

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

@mathiasbynens

This comment has been minimized.

Show comment
Hide comment
@mathiasbynens

mathiasbynens Dec 18, 2013

Contributor

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

Contributor

mathiasbynens commented Dec 18, 2013

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