Skip to content

Commit 8ff444d

Browse files
authoredMar 16, 2024··
fix: Server crashes when receiving an array of Parse.Pointer in the request body (#9012)
1 parent 9cb44c0 commit 8ff444d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
 

‎spec/ParseAPI.spec.js

+18
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,24 @@ describe('miscellaneous', function () {
12671267
});
12681268
});
12691269

1270+
it('test cloud function query parameters with array of pointers', async () => {
1271+
Parse.Cloud.define('echoParams', req => {
1272+
return req.params;
1273+
});
1274+
const headers = {
1275+
'Content-Type': 'application/json',
1276+
'X-Parse-Application-Id': 'test',
1277+
'X-Parse-Javascript-Key': 'test',
1278+
};
1279+
const response = await request({
1280+
method: 'POST',
1281+
headers: headers,
1282+
url: 'http://localhost:8378/1/functions/echoParams',
1283+
body: '{"arr": [{ "__type": "Pointer", "className": "PointerTest" }]}',
1284+
});
1285+
const res = response.data.result;
1286+
expect(res.arr.length).toEqual(1);
1287+
});
12701288
it('can handle null params in cloud functions (regression test for #1742)', done => {
12711289
Parse.Cloud.define('func', request => {
12721290
expect(request.params.nullParam).toEqual(null);

‎src/Routers/FunctionsRouter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { logger } from '../logger';
1212
function parseObject(obj, config) {
1313
if (Array.isArray(obj)) {
1414
return obj.map(item => {
15-
return parseObject(item);
15+
return parseObject(item, config);
1616
});
1717
} else if (obj && obj.__type == 'Date') {
1818
return Object.assign(new Date(obj.iso), obj);

0 commit comments

Comments
 (0)