From dc7566308ead7fe9a968fe3e8d95361ce5fc0d46 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Wed, 10 Aug 2022 10:57:42 +0100 Subject: [PATCH] Ignore escaped double quotes within strings --- packages/server/src/integrations/mongodb.ts | 2 +- packages/server/src/integrations/tests/mongo.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/server/src/integrations/mongodb.ts b/packages/server/src/integrations/mongodb.ts index f3be29e386..cdc1b581b6 100644 --- a/packages/server/src/integrations/mongodb.ts +++ b/packages/server/src/integrations/mongodb.ts @@ -123,7 +123,7 @@ module MongoDBModule { let i = 0 let startIndex = 0 for (let c of params) { - if (c === '"') { + if (c === '"' && (i > 0 && params[i-1] !== '\\')) { inQuotes = !inQuotes } if (c === "{" && !inQuotes) { diff --git a/packages/server/src/integrations/tests/mongo.spec.js b/packages/server/src/integrations/tests/mongo.spec.js index 02d37b18a2..9687723528 100644 --- a/packages/server/src/integrations/tests/mongo.spec.js +++ b/packages/server/src/integrations/tests/mongo.spec.js @@ -289,7 +289,7 @@ describe("MongoDB Integration", () => { }, { "upsert": true, - "extra": "ad{d" + "extra": "ad\\"{\\"d" }`, extra: { collection: "testCollection", actionTypes: "updateOne" }, } @@ -317,7 +317,7 @@ describe("MongoDB Integration", () => { }) expect(args[2]).toEqual({ upsert: true, - extra: "ad{d" + extra: "ad\"{\"d" }) }) })