Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lodash.js
Original file line number Diff line number Diff line change
Expand Up @@ -6589,14 +6589,18 @@
}

/**
* Gets the value at `key`, unless `key` is "__proto__".
* Gets the value at `key`, unless `key` is "__proto__" or "constructor".
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function safeGet(object, key) {
if (key === 'constructor' && typeof object[key] === 'function') {
return;
}

if (key == '__proto__') {
return;
}
Expand Down
11 changes: 11 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4712,6 +4712,17 @@
var actual = _.defaultsDeep({ 'a': ['abc'] }, { 'a': 'abc' });
assert.deepEqual(actual.a, ['abc']);
});

QUnit.test('should not indirectly merge `Object` properties', function(assert) {
assert.expect(1);

_.defaultsDeep({}, { 'constructor': { 'a': 1 } });

var actual = 'a' in Object;
delete Object.a;

assert.notOk(actual);
});
}());

/*--------------------------------------------------------------------------*/
Expand Down