fix: Server crashes when receiving an array of Parse.Pointer in the request body (#9012)
This commit is contained in:
@@ -1267,6 +1267,24 @@ 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 => {
|
it('can handle null params in cloud functions (regression test for #1742)', done => {
|
||||||
Parse.Cloud.define('func', request => {
|
Parse.Cloud.define('func', request => {
|
||||||
expect(request.params.nullParam).toEqual(null);
|
expect(request.params.nullParam).toEqual(null);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { logger } from '../logger';
|
|||||||
function parseObject(obj, config) {
|
function parseObject(obj, config) {
|
||||||
if (Array.isArray(obj)) {
|
if (Array.isArray(obj)) {
|
||||||
return obj.map(item => {
|
return obj.map(item => {
|
||||||
return parseObject(item);
|
return parseObject(item, config);
|
||||||
});
|
});
|
||||||
} else if (obj && obj.__type == 'Date') {
|
} else if (obj && obj.__type == 'Date') {
|
||||||
return Object.assign(new Date(obj.iso), obj);
|
return Object.assign(new Date(obj.iso), obj);
|
||||||
|
|||||||
Reference in New Issue
Block a user