From 66e36039d8af654cfa0284666c0ddd94975dcb52 Mon Sep 17 00:00:00 2001 From: Ziv Chen Date: Mon, 15 Jan 2024 17:02:57 +0200 Subject: [PATCH] fix: Server crashes when receiving an array of `Parse.Pointer` in the request body (#8784) --- spec/ParseAPI.spec.js | 19 +++++++++++++++++++ src/Routers/FunctionsRouter.js | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index 9b1a97af87..4f8190a4a6 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -1267,6 +1267,25 @@ describe('miscellaneous', function () { }); }); + it('test cloud function query parameters with array of pointers', async () => { + Parse.Cloud.define('echoParams', req => { + return req.params; + }); + const headers = { + 'Content-Type': 'application/json', + 'X-Parse-Application-Id': 'test', + 'X-Parse-Javascript-Key': 'test', + }; + const response = await request({ + method: 'POST', + headers: headers, + url: 'http://localhost:8378/1/functions/echoParams', + body: '{"arr": [{ "__type": "Pointer", "className": "PointerTest" }]}', + }); + const res = response.data.result; + expect(res.arr.length).toEqual(1); + }); + it('can handle null params in cloud functions (regression test for #1742)', done => { Parse.Cloud.define('func', request => { expect(request.params.nullParam).toEqual(null); diff --git a/src/Routers/FunctionsRouter.js b/src/Routers/FunctionsRouter.js index bb4b959ebe..eab76eeb1b 100644 --- a/src/Routers/FunctionsRouter.js +++ b/src/Routers/FunctionsRouter.js @@ -12,7 +12,7 @@ import { logger } from '../logger'; function parseObject(obj, config) { if (Array.isArray(obj)) { return obj.map(item => { - return parseObject(item); + return parseObject(item, config); }); } else if (obj && obj.__type == 'Date') { return Object.assign(new Date(obj.iso), obj);