Skip to content

Commit 5bcc925

Browse files
committed
Added compiled files
1 parent 7d88fd2 commit 5bcc925

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

commonjs/core.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,10 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
185185
}
186186
while (true) {
187187
key = keys[t];
188-
if (banPrototypeModifications && key == '__proto__') {
189-
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');
188+
if (banPrototypeModifications &&
189+
(key == '__proto__' ||
190+
(key == 'prototype' && t > 0 && keys[t - 1] == 'constructor'))) {
191+
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');
190192
}
191193
if (validateOperation) {
192194
if (existingPathFragment === undefined) {

commonjs/duplex.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function _generate(mirror, obj, patches, path, invertible) {
131131
var oldVal = mirror[key];
132132
if (helpers_js_1.hasOwnProperty(obj, key) && !(obj[key] === undefined && oldVal !== undefined && Array.isArray(obj) === false)) {
133133
var newVal = obj[key];
134-
if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null) {
134+
if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) {
135135
_generate(oldVal, newVal, patches, path + "/" + helpers_js_1.escapePathComponent(key), invertible);
136136
}
137137
else {

module/core.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export declare function applyOperation<T>(document: T, operation: Operation, val
8181
* @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.
8282
* @return An array of `{newDocument, result}` after the patch
8383
*/
84-
export declare function applyPatch<T>(document: T, patch: Operation[], validateOperation?: boolean | Validator<T>, mutateDocument?: boolean, banPrototypeModifications?: boolean): PatchResult<T>;
84+
export declare function applyPatch<T>(document: T, patch: ReadonlyArray<Operation>, validateOperation?: boolean | Validator<T>, mutateDocument?: boolean, banPrototypeModifications?: boolean): PatchResult<T>;
8585
/**
8686
* Apply a single JSON Patch Operation on a JSON document.
8787
* Returns the updated document.
@@ -107,5 +107,5 @@ export declare function validator(operation: Operation, index: number, document?
107107
* @param document
108108
* @returns {JsonPatchError|undefined}
109109
*/
110-
export declare function validate<T>(sequence: Operation[], document?: T, externalValidator?: Validator<T>): PatchError;
110+
export declare function validate<T>(sequence: ReadonlyArray<Operation>, document?: T, externalValidator?: Validator<T>): PatchError;
111111
export declare function _areEquals(a: any, b: any): boolean;

module/core.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,10 @@ export function applyOperation(document, operation, validateOperation, mutateDoc
183183
}
184184
while (true) {
185185
key = keys[t];
186-
if (banPrototypeModifications && key == '__proto__') {
187-
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');
186+
if (banPrototypeModifications &&
187+
(key == '__proto__' ||
188+
(key == 'prototype' && t > 0 && keys[t - 1] == 'constructor'))) {
189+
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');
188190
}
189191
if (validateOperation) {
190192
if (existingPathFragment === undefined) {

0 commit comments

Comments
 (0)