Merge pull request #410 from Marco129/query-constraints

Throw when query is encoded incorrectly
This commit is contained in:
Fosco Marotto
2016-02-19 11:56:01 -08:00
2 changed files with 59 additions and 0 deletions

View File

@@ -2,11 +2,22 @@
import PromiseRouter from '../PromiseRouter';
import rest from '../rest';
import url from 'url';
export class ClassesRouter {
// Returns a promise that resolves to a {response} object.
handleFind(req) {
let body = Object.assign(req.body, req.query);
let options = {};
let allowConstraints = ['skip', 'limit', 'order', 'count', 'keys',
'include', 'redirectClassNameForKey', 'where'];
for (var key in body) {
if (allowConstraints.indexOf(key) === -1) {
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Improper encode of parameter');
}
}
if (body.skip) {
options.skip = Number(body.skip);
}