Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Server crashes when receiving an array of Parse.Pointer in the request body #8784

Merged
merged 9 commits into from Jan 15, 2024
20 changes: 20 additions & 0 deletions spec/ParseAPI.spec.js
Expand Up @@ -1267,6 +1267,26 @@ describe('miscellaneous', function () {
});
});

it('test cloud function query parameters with array of pointers', async done => {
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);
done();
});
mtrezza marked this conversation as resolved.
Show resolved Hide resolved

it('can handle null params in cloud functions (regression test for #1742)', done => {
Parse.Cloud.define('func', request => {
expect(request.params.nullParam).toEqual(null);
Expand Down
2 changes: 1 addition & 1 deletion src/Routers/FunctionsRouter.js
Expand Up @@ -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);
Expand Down