Skip to content

Commit 632cc9c

Browse files
committed
Fix __proto__ test case on Node 0.8
1 parent 3f92a15 commit 632cc9c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,14 @@ test('non-object target', function (t) {
629629

630630
test('__proto__ is merged as an own property', function (t) {
631631
var malicious = JSON.parse('{ "fred": 1, "__proto__": { "george": 1 } }');
632-
var target = {};
633-
extend(true, target, malicious);
634-
t.notOk(target.george);
635-
t.ok(Object.prototype.hasOwnProperty.call(target, '__proto__'));
636-
t.deepEqual(target.__proto__, { george: 1 }); // eslint-disable-line no-proto
632+
// this test isn't valid for earlier versions of V8, which strip __proto__ during JSON.parse()
633+
if (Object.prototype.hasOwnProperty.call(malicious, '__proto__')) {
634+
var target = {};
635+
extend(true, target, malicious);
636+
t.notOk(target.george);
637+
t.ok(Object.prototype.hasOwnProperty.call(target, '__proto__'));
638+
t.deepEqual(target.__proto__, { george: 1 }); // eslint-disable-line no-proto
639+
}
640+
637641
t.end();
638642
});

0 commit comments

Comments
 (0)