Skip to content

Commit 40d9816

Browse files
authored
Merge pull request #7993 from nextcloud/backport/7990/stable31
[stable31] fix: board notify-due
2 parents b296ccc + 97bee01 commit 40d9816

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/Controller/ConfigController.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
namespace OCA\Deck\Controller;
99

10+
use OCA\Deck\Db\Acl;
11+
use OCA\Deck\Db\BoardMapper;
1012
use OCA\Deck\Service\ConfigService;
13+
use OCA\Deck\Service\PermissionService;
1114
use OCP\AppFramework\Http\DataResponse;
1215
use OCP\AppFramework\Http\NotFoundResponse;
1316
use OCP\AppFramework\OCSController;
@@ -18,6 +21,8 @@ public function __construct(
1821
$AppName,
1922
IRequest $request,
2023
private ConfigService $configService,
24+
private PermissionService $permissionService,
25+
private BoardMapper $boardMapper,
2126
) {
2227
parent::__construct($AppName, $request);
2328
}
@@ -35,6 +40,14 @@ public function get(): DataResponse {
3540
* @NoAdminRequired
3641
*/
3742
public function setValue(string $key, $value) {
43+
if (preg_match('/^board:(\d+):/', $key, $matches) === 1) {
44+
$this->permissionService->checkPermission(
45+
$this->boardMapper,
46+
(int)$matches[1],
47+
Acl::PERMISSION_EDIT,
48+
);
49+
}
50+
3851
$result = $this->configService->set($key, $value);
3952
if ($result === null) {
4053
return new NotFoundResponse();

lib/Service/ConfigService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,12 @@ public function set($key, $value) {
158158
$result = $value;
159159
break;
160160
case 'board':
161-
[$boardId, $boardConfigKey] = explode(':', $key);
161+
// extra check that user only send one of the allowed board settings and not something random
162+
$parts = explode(':', $key, 3);
163+
if (count($parts) < 3) {
164+
break;
165+
}
166+
$boardConfigKey = $parts[2];
162167
if ($boardConfigKey === 'notify-due' && !in_array($value, [self::SETTING_BOARD_NOTIFICATION_DUE_ALL, self::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED, self::SETTING_BOARD_NOTIFICATION_DUE_OFF], true)) {
163168
throw new BadRequestException('Board notification option must be one of: off, assigned, all');
164169
}

0 commit comments

Comments
 (0)