Skip to content

Commit 796d566

Browse files
committed
Be even safer by getting a hasOwnProperty reference early
hapijs/bourne#7 (comment)
1 parent 22d6a7c commit 796d566

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
const hasOwnProperty = Object.prototype.hasOwnProperty;
34

45
const internals = {
56
suspectRx: /"(?:_|\\u005f)(?:_|\\u005f)(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006f)(?:t|\\u0074)(?:o|\\u006f)(?:_|\\u005f)(?:_|\\u005f)"\s*\:/
@@ -65,7 +66,7 @@ exports.scan = function (obj, options) {
6566
next = [];
6667

6768
for (const node of nodes) {
68-
if (Object.prototype.hasOwnProperty.call(node, '__proto__')) {
69+
if (hasOwnProperty.call(node, '__proto__')) {
6970
if (options.protoAction !== 'remove') {
7071
throw new SyntaxError('Object contains forbidden prototype property');
7172
}

0 commit comments

Comments
 (0)