Skip to content

Commit 8453e00

Browse files
Contacts|Contactgroups endpoints: Only allow filter on GET method
1 parent 898009b commit 8453e00

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

application/controllers/ApiV1ContactgroupsController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@ public function indexAction(): void
6060
$this->httpBadRequest('The given identifier is not a valid UUID');
6161
}
6262

63+
$filterStr = rawurldecode(Url::fromRequest()->getQueryString());
64+
if ($method !== 'GET' && $filterStr) {
65+
$this->httpBadRequest('Filter is only allowed for GET requests');
66+
}
67+
6368
$filter = FilterProcessor::assembleFilter(
64-
QueryString::fromString(rawurldecode(Url::fromRequest()->getQueryString()))
69+
QueryString::fromString($filterStr)
6570
->on(
6671
QueryString::ON_CONDITION,
6772
function (Filter\Condition $condition) {

application/controllers/ApiV1ContactsController.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,13 @@ public function indexAction(): void
6565
$this->httpBadRequest('The given identifier is not a valid UUID');
6666
}
6767

68+
$filterStr = rawurldecode(Url::fromRequest()->getQueryString());
69+
if ($method !== 'GET' && $filterStr) {
70+
$this->httpBadRequest('Filter is only allowed for GET requests');
71+
}
72+
6873
$filter = FilterProcessor::assembleFilter(
69-
QueryString::fromString(rawurldecode(Url::fromRequest()->getQueryString()))
74+
QueryString::fromString($filterStr)
7075
->on(
7176
QueryString::ON_CONDITION,
7277
function (Filter\Condition $condition) {
@@ -164,10 +169,6 @@ function (Filter\Condition $condition) {
164169

165170
exit;
166171
case 'POST':
167-
if ($filter !== null) {
168-
$this->httpBadRequest('Cannot filter on POST');
169-
}
170-
171172
$data = $this->getValidatedData();
172173

173174
$db->beginTransaction();

0 commit comments

Comments
 (0)