Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Guard against object with own property "hasOwnProperty" #51

Closed
Krinkle opened this issue May 23, 2014 · 2 comments
Closed

Guard against object with own property "hasOwnProperty" #51

Krinkle opened this issue May 23, 2014 · 2 comments

Comments

@Krinkle
Copy link
Owner

Krinkle commented May 23, 2014

From timotijhof on September 25, 2011 18:19:11

Although it's a fairly rare edge case, suppose an object looks like this:

var FooBar = {
isAwesome: true,
getProp: function(){ },
hasOwnProperty: true
};

Then the check that fixed issue 50 in r38 will fail since it would use the own property "hasOwnProperty" instead of the Object.prototype.hasOwnProperty function.

Fix by using Object.prototype.hasOwnProperty.call( foobar, key );
instead of foobar.hasOwnProperty( key ); which depends on the fact that the objet itself will never have a property by that name.

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=51

@Krinkle
Copy link
Owner Author

Krinkle commented May 23, 2014

From timotijhof on September 25, 2011 09:21:39

Fixed in r39 .

@Krinkle
Copy link
Owner Author

Krinkle commented May 23, 2014

From krinklemail on September 25, 2011 09:22:18

Thx

Status: Fixed

@Krinkle Krinkle closed this as completed May 23, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant