Skip to content

Commit

Permalink
fix(utils): make clone() only copy own properties
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Feb 12, 2021
1 parent bb185d9 commit 2dd768d
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ exports.cloneObject = function cloneObject(obj, options) {
var ret = {};
var hasKeys;
var val;
var k;

for (k in obj) {
for (const k of Object.keys(obj)) {
// Not technically prototype pollution because this wouldn't merge properties
// onto `Object.prototype`, but avoid properties like __proto__ as a precaution.
if (specialProperties.indexOf(k) !== -1) {
Expand Down Expand Up @@ -295,13 +294,7 @@ exports.isArray = function(arg) {
* Object.keys helper
*/

exports.keys = Object.keys || function(obj) {
var keys = [];
for (var k in obj) if (obj.hasOwnProperty(k)) {
keys.push(k);
}
return keys;
};
exports.keys = Object.keys;

/**
* Basic Object.create polyfill.
Expand Down

0 comments on commit 2dd768d

Please sign in to comment.