Skip to content

Commit 551949d

Browse files
committed
Minor mitigation
1 parent 820855a commit 551949d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/utils.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
'use strict';
2626

2727
var regExpChars = /[|\\{}()[\]^$+*?.]/g;
28+
var hasOwnProperty = Object.prototype.hasOwnProperty;
29+
var hasOwn = function (obj, key) { return hasOwnProperty.apply(obj, [key]); };
2830

2931
/**
3032
* Escape characters reserved in regular expressions.
@@ -116,6 +118,12 @@ exports.shallowCopy = function (to, from) {
116118
from = from || {};
117119
if ((to !== null) && (to !== undefined)) {
118120
for (var p in from) {
121+
if (!hasOwn(from, p)) {
122+
continue;
123+
}
124+
if (p === '__proto__' || p === 'constructor') {
125+
continue;
126+
}
119127
to[p] = from[p];
120128
}
121129
}
@@ -141,6 +149,12 @@ exports.shallowCopyFromList = function (to, from, list) {
141149
for (var i = 0; i < list.length; i++) {
142150
var p = list[i];
143151
if (typeof from[p] != 'undefined') {
152+
if (!hasOwn(from, p)) {
153+
continue;
154+
}
155+
if (p === '__proto__' || p === 'constructor') {
156+
continue;
157+
}
144158
to[p] = from[p];
145159
}
146160
}

0 commit comments

Comments
 (0)