Skip to content

Commit f486879

Browse files
committed
Throw only if the constructor key has a child named prototype
1 parent d65152e commit f486879

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ function scan (obj, { protoAction = 'error', constructorAction = 'error' } = {})
7676
delete node.__proto__ // eslint-disable-line no-proto
7777
}
7878

79-
if (constructorAction !== 'ignore' && Object.prototype.hasOwnProperty.call(node, 'constructor')) { // Avoid calling node.hasOwnProperty directly
79+
if (constructorAction !== 'ignore' &&
80+
Object.prototype.hasOwnProperty.call(node, 'constructor') &&
81+
Object.prototype.hasOwnProperty.call(node.constructor, 'prototype')) { // Avoid calling node.hasOwnProperty directly
8082
if (constructorAction === 'error') {
8183
throw new SyntaxError('Object contains forbidden prototype property')
8284
}

0 commit comments

Comments
 (0)