Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
Enhance constructor/prototype handling
Browse files Browse the repository at this point in the history
  • Loading branch information
alromh87 committed Oct 22, 2020
1 parent 0f6c19f commit 7d88fd2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ export function applyOperation<T>(document: T, operation: Operation, validateOpe
}
while (true) {
key = keys[t];

if(banPrototypeModifications &&
(key == '__proto__' || key == 'constructor' || key == 'prototype')
(key == '__proto__' ||
(key == 'prototype' && t>0 && keys[t-1] == 'constructor'))
) {
throw new TypeError('JSON-Patch: modifying `__proto__` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README');
throw new TypeError('JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README');
}

if (validateOperation) {
Expand Down

0 comments on commit 7d88fd2

Please # to comment.