Skip to content

Commit dcdca3c

Browse files
committed
fix: use exact routable path match for nested batch check
1 parent e2595cf commit dcdca3c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/batch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ async function handleBatch(router, req) {
7878
if (!restRequest || typeof restRequest !== 'object' || typeof restRequest.path !== 'string') {
7979
throw new Parse.Error(Parse.Error.INVALID_JSON, 'batch request path must be a string');
8080
}
81-
if (restRequest.method === 'POST' && restRequest.path.endsWith(batchPath)) {
82-
throw new Parse.Error(Parse.Error.INVALID_JSON, 'nested batch requests are not allowed');
83-
}
8481
}
8582

8683
// The batch paths are all from the root of our domain.
@@ -104,6 +101,9 @@ async function handleBatch(router, req) {
104101
const rateLimits = req.config.rateLimits || [];
105102
for (const restRequest of req.body.requests) {
106103
const routablePath = makeRoutablePath(restRequest.path);
104+
if ((restRequest.method || 'GET').toUpperCase() === 'POST' && routablePath === batchPath) {
105+
throw new Parse.Error(Parse.Error.INVALID_JSON, 'nested batch requests are not allowed');
106+
}
107107
for (const limit of rateLimits) {
108108
const pathExp = limit.path.regexp || limit.path;
109109
if (!pathExp.test(routablePath)) {

0 commit comments

Comments
 (0)